OldSchool Library
I/O routines

Macros

#define VirtualFileWrite(ptr, size, n, f)
 Writes data to a file.
 
#define VirtualFileRead(ptr, size, n, f)
 Reads data from a file.
 
#define VirtualFileGetc(f)
 Reads a single character from a file.
 
#define VirtualFilePutc(caractere, f)
 Writes a single character to a file.
 
#define VirtualFileGets(str, maxLen, f)
 Reads a string from a file.
 
#define VirtualFilePuts(s, f)
 Writes a string to a file.
 
#define VirtualFileSeek(f, offset, whence)
 Sets the current file position.
 
#define VirtualFileTell(f)
 Returns the current file pointer position.
 
#define VirtualFileEof(f)
 Checks if the end of a file has been reached.
 

Detailed Description

Routines for reading/writing to a virtual file.

Macro Definition Documentation

◆ VirtualFileWrite

#define VirtualFileWrite ( ptr,
size,
n,
f )
Value:
(VirtualFileGetSource(f)->fWrite(ptr, size, n, f))
#define VirtualFileGetSource(vf)
Gets a pointer to the virtual file source associated with a given virtual file.
Definition VirtualFile.h:231

Writes data to a file.

Parameters
ptrPointer to the data to write.
sizeSize of each element to write.
nNumber of elements to write.
fPointer to the virtual file.
Returns
The number of bytes effectively written.

◆ VirtualFileRead

#define VirtualFileRead ( ptr,
size,
n,
f )
Value:
(VirtualFileGetSource(f)->fRead(ptr, size, n, f))

Reads data from a file.

Parameters
ptrPointer to the buffer where the data will be stored.
sizeSize of each element to read.
nNumber of elements to read.
fPointer to the virtual file.
Returns
The number of bytes effectively read.

◆ VirtualFileGetc

#define VirtualFileGetc ( f)
Value:
(VirtualFileGetSource(f)->fGetc(f))

Reads a single character from a file.

Parameters
fPointer to the virtual file.
Returns
The next character (byte) in the file.

◆ VirtualFilePutc

#define VirtualFilePutc ( caractere,
f )
Value:
(VirtualFileGetSource(f)->fPutc(caractere, f))

Writes a single character to a file.

Parameters
caractereThe character to write.
fPointer to the virtual file.
Returns
The character value if successful, -1 otherwise.

◆ VirtualFileGets

#define VirtualFileGets ( str,
maxLen,
f )
Value:
(VirtualFileGetSource(f)->fGets(str, maxLen, f))

Reads a string from a file.

Parameters
strPointer to the buffer where the string will be stored.
maxLenMaximum length of the string.
fPointer to the virtual file.
Returns
A pointer to the read string.

◆ VirtualFilePuts

#define VirtualFilePuts ( s,
f )
Value:
(VirtualFileGetSource(f)->fPuts(s, f))

Writes a string to a file.

Parameters
sPointer to the string to write.
fPointer to the virtual file.

◆ VirtualFileSeek

#define VirtualFileSeek ( f,
offset,
whence )
Value:
(VirtualFileGetSource(f)->fSeek(f, offset, whence))

Sets the current file position.

Parameters
fPointer to the virtual file.
offsetOffset from the whence parameter.
whencePosition to base the offset from (SEEK_SET, SEEK_CUR, SEEK_END).

◆ VirtualFileTell

#define VirtualFileTell ( f)
Value:
(VirtualFileGetSource(f)->fTell(f))

Returns the current file pointer position.

Parameters
fPointer to the virtual file.
Returns
The current file position.

◆ VirtualFileEof

#define VirtualFileEof ( f)
Value:
(VirtualFileGetSource(f)->fEof(f))

Checks if the end of a file has been reached.

Parameters
fPointer to the virtual file.
Returns
1 if the end of the file is reached, 0 otherwise.