Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

File Access
[FILE - Class for file management]


Functions

FILE otFILE.fopen (const char *filename, int fileAccessMode)
bool otFILE.fclose (FILE f)
U32 otFILE.fsize (FILE f)
U32 otFILE.fsize (const char *filename)
bool otFILE.fread (FILE f, void *buffer, U32 len, U32 &rlen)
bool otFILE.fwrite (FILE f, void *buffer, U32 len, U32 &wlen)
bool otFILE.fseek (FILE f, U32 pos)
U32 otFILE.ftell (FILE f)
bool otFILE.fputs (const char *text, FILE f, U32 *written=0)
char * otFILE.fgets (char *buffer, U32 bufferSize, FILE f)
bool otFILE.fputc (char ch, FILE f)
char otFILE.fgetc (FILE f, bool *ok=0)
char * otFILE.fgetline (FILE f, U32 maxLen=4096, char eol= '\n')
char * otFILE.freadline (char *buffer, U32 bufferSize, FILE f, char eol= '\n', bool stripEol=true, bool *truncated=0)
bool otFILE.ftruncate (FILE f)
bool otFILE.fsync (FILE f)
bool otFILE.feof (FILE f)
int otFILE.fprintf (FILE f, const char *fmt,...)
int otFILE.fscanf (FILE f, const char *fmt,...)
bool otFILE.fsave (const char *filename, void *src, U32 len)
bool otFILE.fsave (FILE f, const char *data, U32 n)
bool otFILE.fsave (FILE f, U8 data)
bool otFILE.fsave (FILE f, U16 data)
bool otFILE.fsave (FILE f, U32 data)
bool otFILE.fload (FILE f, U8 &data)
bool otFILE.fload (FILE f, U16 &data)
bool otFILE.fload (FILE f, U32 &data)
void * otFILE.fload (const char *filename, U32 &len, bool &ok)
FINF otFILE.fnew ()
void otFILE.fend (FINF d)

Function Documentation

bool otFILE.fclose (  FILE  f  )  [inherited]
 

Closes an open file.

Parameters:
f Pointer to the open file object structure to be closed.
Returns:
True on success

void otFILE.fend (  FINF  d  )  [inherited]
 

Free a file info data structure

Parameters:
d File info data structure to be freed

bool otFILE.feof (  FILE  f  )  [inherited]
 

Function tests for end-of-file on a file.

Parameters:
f Pointer to the open file object structure.
Returns:
False if the read/write pointer has reached end of the file; otherwise it returns true.

char otFILE.fgetc (  FILE  f,
bool *  ok = 0
)  [inherited]
 

Gets a character from the file.

Parameters:
f Pointer to the open file object structure.
ok If defined will be set or cleared according operation results
Returns:
Character

char* otFILE.fgetline (  FILE  f,
U32  maxLen = 4096,
char  eol = '\n'
)  [inherited]
 

Extracts characters from is and stores them into string until the delimitation character eol is found

Parameters:
f Pointer to the open file object structure.
maxLen Maximum number of characters to read.
eol End of line character.
Returns:
Character string

char* otFILE.fgets (  char *  buffer,
U32  bufferSize,
FILE  f
)  [inherited]
 

Reads a string from the file.

Parameters:
buffer Pointer to read buffer to store the read string.
bufferSize Size of the read buffer in unit of item.
f Pointer to the open file object structure.
Returns:
True on success

void* otFILE.fload (  const char *  filename,
U32 &  len,
bool &  ok
)  [inherited]
 

Open a file and read requested number of bytes to be stored in a buffer. The buffer is automatically allocated.

Parameters:
filename File path name.
len Returns the number of bytes read
ok Returns true on success
Returns:
Pointer to allocated buffer

bool otFILE.fload (  FILE  f,
U32 &  data
)  [inherited]
 

Read a double word from an opened file.

Parameters:
f Pointer to the open file object structure.
data Double word to be read
Returns:
True on success

bool otFILE.fload (  FILE  f,
U16 &  data
)  [inherited]
 

Read a word from an opened file.

Parameters:
f Pointer to the open file object structure.
data Word to be read
Returns:
True on success

bool otFILE.fload (  FILE  f,
U8 &  data
)  [inherited]
 

Read a byte from an opened file.

Parameters:
f Pointer to the open file object structure.
data Byte to be read
Returns:
True on success

FINF otFILE.fnew (   )  [inherited]
 

Create a file info data structure

Returns:
File info data structure

FILE otFILE.fopen (  const char *  filename,
int  fileAccessMode
)  [inherited]
 

Function opens a file.

Parameters:
filename Pointer to the null-terminated string that specifies the file name to open or create.
fileAccessMode Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags. See FileAccess
Returns:
Pointer to file object structure or 0 when fail.

int otFILE.fprintf (  FILE  f,
const char *  fmt,
  ...
)  [inherited]
 

Function writes formatted string to the file.

Parameters:
f Pointer to the open file object structure.
fmt Pointer to the null '\0' terminated format string. The terminator character will not be output.
... Optional arguments...
Returns:
When the string was written successfuly, it returns number of character encoding units written to the file. When the function failed due to disk full or any error, an EOF (-1) will be returned.

bool otFILE.fputc (  char  ch,
FILE  f
)  [inherited]
 

Puts a character to the file.

Parameters:
ch A character to write.
f Pointer to the open file object structure.
Returns:
True on success

bool otFILE.fputs (  const char *  text,
FILE  f,
U32 *  written = 0
)  [inherited]
 

Writes a string to the file.

Parameters:
text Pointer to the null terminated string to be written. The terminator character will not be written.
f Pointer to the open file object structure.
written If a valid variable pointer (!= 0) returns number of character encoding units written to the file.
Returns:
True on success

bool otFILE.fread (  FILE  f,
void *  buffer,
U32  len,
U32 &  rlen
)  [inherited]
 

Reads data from a file.

Parameters:
f Pointer to the open file object.
buffer Pointer to the buffer to store the read data.
len Number of bytes to read in range of U32 type.
rlen Pointer to the U32 variable that receives number of bytes read.
Returns:
True on success

char* otFILE.freadline (  char *  buffer,
U32  bufferSize,
FILE  f,
char  eol = '\n',
bool  stripEol = true,
bool *  truncated = 0
)  [inherited]
 

Reads one delimited text line into a caller-provided buffer. The buffer is always NUL terminated when bufferSize > 0. The function consumes the complete physical line even when the supplied buffer is too small; in that case *truncated is set to true.

Parameters:
buffer Destination buffer.
bufferSize Destination buffer size including the NUL terminator.
f Pointer to the open file object structure.
eol Line delimiter.
stripEol If true the delimiter is not copied and a trailing CR is removed when eol is LF.
truncated Optional flag set when the physical line did not fit.
Returns:
buffer on a successfully read line (including an empty line), or 0 on EOF before any character or on I/O/argument error.

bool otFILE.fsave (  FILE  f,
U32  data
)  [inherited]
 

Write a double word in a opened file.

Parameters:
f Pointer to the open file object structure.
data Double word to be written
Returns:
True on success

bool otFILE.fsave (  FILE  f,
U16  data
)  [inherited]
 

Write a word in a opened file.

Parameters:
f Pointer to the open file object structure.
data Word to be written
Returns:
True on success

bool otFILE.fsave (  FILE  f,
U8  data
)  [inherited]
 

Write a byte in a opened file.

Parameters:
f Pointer to the open file object structure.
data Byte to be written
Returns:
True on success

bool otFILE.fsave (  FILE  f,
const char *  data,
U32  n
)  [inherited]
 

Save in a opened file data

Parameters:
f Pointer to the open file object structure.
data Buffer pointer
n Size of data
Returns:
True on success

bool otFILE.fsave (  const char *  filename,
void *  src,
U32  len
)  [inherited]
 

Create a file and save a buffer on it.

Parameters:
filename File path name.
src Buffer pointer
len Number of bytes to be written
Returns:
True on success

int otFILE.fscanf (  FILE  f,
const char *  fmt,
  ...
)  [inherited]
 

Reads data from the stream and stores them according to the parameter format into the locations pointed by the additional arguments.

Parameters:
f Pointer to the open file object structure.
fmt Pointer to the null '\0' terminated format string. The terminator character will not be output.
... Optional arguments...
Returns:
On success, the function returns the number of items of the argument list successfully filled.

bool otFILE.fseek (  FILE  f,
U32  pos
)  [inherited]
 

This function moves the file read/write pointer of an open file object. It can also be used to expand the file size (cluster pre-allocation).

Parameters:
f Pointer to the open file object.
pos Byte offset from top of the file to set read/write pointer.
Returns:
True on success

U32 otFILE.fsize (  const char *  filename  )  [inherited]
 

Gets the size of a file.

Parameters:
filename Path name of a file to be check the size.
Returns:
The size of the file in unit of byte.

U32 otFILE.fsize (  FILE  f  )  [inherited]
 

Gets the size of a file.

Parameters:
f Pointer to the open file object structure.
Returns:
The size of the file in unit of byte.

bool otFILE.fsync (  FILE  f  )  [inherited]
 

Function flushes the cached information of a writing file.

Parameters:
f Pointer to the open file object to be flushed.
Returns:
True on success

U32 otFILE.ftell (  FILE  f  )  [inherited]
 

The ftell function gets the current read/write pointer of a file.

Parameters:
f Pointer to the open file object structure.
Returns:
Returns current read/write pointer of the file.

bool otFILE.ftruncate (  FILE  f  )  [inherited]
 

Function truncates the file size.

Parameters:
f Pointer to the open file object to be truncated.
Returns:
True on success

bool otFILE.fwrite (  FILE  f,
void *  buffer,
U32  len,
U32 &  wlen
)  [inherited]
 

Writes data to a file.

Parameters:
f Pointer to the open file object structure.
buffer Pointer to the data to be written.
len Specifies number of bytes to write in range of U32 type.
wlen Pointer to the U32 variable that receives the number of bytes written.
Returns:
True on success
footer

otStudio - Library Reference - (C) 2020-25 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0