In a message dated 7/25/00 11:24:51 AM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:

<< Hi
         I want to use File Streaming API in my application. I have
 tried with FileWrite( ) and FileRead( ) calls. I am able to write some
 bytes into a file. But reading that file always returns zero objects.
 I didn't got any errors also. Can anybody suggest some way to do this.
 
 The code follows:
 
 int file(void)
 {
     FileHand tmpFile = NULL;
   Int32 written, read;
   char write_buffer[4] = "abcd";
   char read_buffer[4] = "    ";
 tmpFile = FileOpen (0, "ptt1.txt", 0, 0, fileModeReadWrite, NULL);
   if (tmpFile == NULL)
   {
    printf("Error opening file");
   }
 
   written = FileWrite (tmpFile, (void *)write_buffer, 1, 4, &err);
   printf("Bytes Written = %d.\n",(int)written);
 
   read = FileRead (tmpFile, (void *)read_buffer, 1, 4, &err);
   printf("Bytes Read = %d.\n",(int)read);
 err = FileClose(tiffFile);
 return 0;
 }
 debugging returns err = 0
 
 Thanks in advance
 
 venkatesh >>

Just as an offhand observation of your function: if you are trying to read 
the same bytes that you just wrote then you're going to want to set the file 
pointer back to the beginning of the file.  Otherwise, you will be attempting 
to read bytes from the end of the file, in which case you would be getting 
the read problem that you describe.  There's probably a FileSeek() function 
that you can use to reset the file pointer to anywhere that you desire 
(BEGINNING, CURRENT, END).
Hope this helps, -Pete

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to