Cannot write a file!! - skooter500

09-May-08 06:47:10
Apologies for cross positing. I posted this in the PocketPC forum
originally. I think  I should have posted it here:

Hi,

I am trying to port my program TunePal:

http://www.bryanduggan.com/TunePal.html

To Windows Mobile Pocket PC to run on my Palm Treo 500v smartphone. I
cant get this simple file writing code to work:

void testFile()
{
FILE * fp = NULL;

fp = fopen("\\temp\\test.txt", "w");
int r = fprintf(fp, "Hello world!!\n");
fclose(fp);

HANDLE file;
char * msg = "Hello world!";
CreateFile(L"\\temp\\test1.txt", GENERIC_WRITE, 0, 0,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, file);
WriteFile(file, msg, strlen(msg), 0, 0);
CloseHandle(file);
exit(0);

}

In both cases, the files are created correctly, but there is nothing
in the contents (the length of the files is 0 bytes. Also the value of
r is 0 after the call to fprintf. I have tried adding fflush before
closing the files and writing files to various locations (internal
memory and an SD card inserted in the device) In all cases, the files
are created, but there is no contents. Ive also had problems with this
program:

http://classic.pocketgear.com/software_detail.asp?id=26010&associateid=9

I dont know if its related, but it wont write a file copy of my sim
card.

Is there some strange problem writing files on this device or am I
going mad!

Thanks,

Bryan
button
 
 

Cannot write a file!! - skooter500

09-May-08 06:47:11
Doh. I figured it out. My bad. The project was compiled with a version
fprintf from the timidity MIDI library which has no body!!

Bryan
button
 


emulator skin environment