tfFSReadFileRecord

Jump to: navigation, search

Table of Contents >> Application Reference >> File System Interface


#include <trsocket.h>


int tfFSReadFileRecord (
void * userDataPtr,
void * fileDataPtr,
char * bufferPtr,
int bufferSize,
int eorPtr
);


Function Description

Given the unique user data pointer as returned by tfFSUserLogin() and a file data pointer as returned by tfFSOpenFile(), this function reads until it reaches 'bufferSize' bytes or end of record (whichever comes first). If end of record has been reached it stores 1 in the integer pointed to by 'eorPtr', otherwise it stores 0. If the file system does not support records, then the system end of line (i.e. <CR><LF> for DOS, <LF> for UNIX) is used for the end of record. This routine should convert every end of line (i.e. <CR><LF> for DOS, <LF> for Unix) to an end of record, i.e. store 1 in 'eorPtr' when the end of line character(s) have been read; the end of line character(s) themselves should not be copied into the buffer pointed to by 'bufferPtr'.

To indicate that end of file was reached, this routine stores 0 in 'eorPtr', and returns 0 to indicate that no characters were read. Note that if 1 is stored in 'eorPtr', this does not indicate end of file, since when a blank line consisting of nothing but the end of line characters (i.e. <CR><LF> for DOS, <LF> for UNIX) occurs in the middle of an ASCII text file, this routine returns 0 to indicate that no characters were read (since the end of line characters are stripped out and are not copied into the buffer pointed to by 'bufferPtr') and stores 1 in 'eorPtr' to indicate end of record.


Parameters

  • userDataPtr
    Pointer to user data structure as returned by tfFSUserLogin().
  • fileDataPtr
    Pointer to file data structure as returned by tfFSOpenFile().
  • bufferPtr
    Pointer to buffer where to copy the data from the file.
  • bufferSize
    Size in bytes of the buffer.
  • eorPtr
    Pointer to end of record.


Returns

  • >0
    Number of copied bytes (not including end of record).
  • 0
    End of file has been reached.
  • -1
    Failure.


Table of Contents >> Application Reference >> File System Interface