Xiqual 0.7.2
In file include/files.h: Autofile structure.
-
int w
- Boolean indicating the file is open for writing.
-
size_t size
- Size of file.
-
size_t pos
- Current position in an open file.
-
size_t read
- Number of bytes read in last read operation.
-
char* name
- Name of file.
-
char* buf
- A buffer used in file_read() and file_write() operations.
-
size_t bufsize
- Size of buf element.
-
FILE* f
- The actual FILE pointer.
-
void (*readhook)(char* buf, size_t len)
- Hook called when reading.
-
void (*writehook)(char* buf, size_t len)
- Hook called when writing.
Documentation
Autofile structure.
Use file_new() to create a structure with a filename.
The other file_* operations can be used to read, write
and seek in the file.
int w
-
Boolean indicating the file is open for writing.
It will be created if it doesn't exist.
size_t size
-
Size of file.
Writing operations will add the number of bytes written from
each call.
size_t pos
-
Current position in an open file.
This usually equals size with a file being written to.
size_t read
-
Number of bytes read in last read operation.
The pos element will point to the point after last byte read.
Start point of the last read chunk of data is pos - read.
char* name
-
Name of file.
No special checking is made on this name to ensure it is valid
for the OS to create.
char* buf
-
A buffer used in file_read() and file_write() operations.
You must create this buffer with file_initbuf(). The buffersize
shouldn't need to be larger than the size of a file. You may not
always know how large a file being written will be, so a smaller
buffer of a few kilobytes is advisable.
size_t bufsize
-
Size of buf element.
file_read() will not read more than this much per call.
The previous buffer contents are of course lost. No special
care is made to clear the contents before reading, so do not
expect everything to be nicely NULL-terminated.
FILE* f
-
The actual FILE pointer.
For internal use.
void (*readhook)(char* buf, size_t len)
-
Hook called when reading.
This is called right after reading in all data and ensuring anything
was read. See md5.c in the base Xiqual directory for an example of
simple usage of a hook.
void (*writehook)(char* buf, size_t len)
-
Hook called when writing.
Before actually writing, this is called. Note that file_write() may
not always be able to write the entire requested buffer (if disk is
full, permissions are wrong etc.), so you should compare the return
value with the requested size.
- Author:
- Ronny Bangsund
- See Also:
- file_new(), file_free(), file_getsize(), file_initbuf(), file_load(),
file_seek(), file_scan(), file_read(), file_write(), file_readhook(),
file_writehook()
Alphabetic index
This page was generated with the help of DOC++.