Xiqual 0.7.2

In file include/files.h:

typedef struct autofile

Autofile structure.

[more]int w
Boolean indicating the file is open for writing.
[more]size_t size
Size of file.
[more]size_t pos
Current position in an open file.
[more]size_t read
Number of bytes read in last read operation.
[more]char* name
Name of file.
[more]char* buf
A buffer used in file_read() and file_write() operations.
[more]size_t bufsize
Size of buf element.
[more]FILE* f
The actual FILE pointer.
[more]void (*readhook)(char* buf, size_t len)
Hook called when reading.
[more]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.
oint w
Boolean indicating the file is open for writing. It will be created if it doesn't exist.

osize_t size
Size of file. Writing operations will add the number of bytes written from each call.

osize_t pos
Current position in an open file. This usually equals size with a file being written to.

osize_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.

ochar* name
Name of file. No special checking is made on this name to ensure it is valid for the OS to create.

ochar* 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.

osize_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.

oFILE* f
The actual FILE pointer. For internal use.

ovoid (*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.

ovoid (*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++.