DDraceNetwork Docs
|
Typedefs | |
typedef struct ASYNCIO | ASYNCIO |
typedef void * | IOHANDLE |
Enumerations | |
enum | { IOFLAG_READ = 1 , IOFLAG_WRITE = 2 , IOFLAG_APPEND = 4 , IOSEEK_START = 0 , IOSEEK_CUR = 1 , IOSEEK_END = 2 } |
Functions | |
IOHANDLE | io_open (const char *filename, int flags) |
unsigned | io_read (IOHANDLE io, void *buffer, unsigned size) |
void | io_read_all (IOHANDLE io, void **result, unsigned *result_len) |
char * | io_read_all_str (IOHANDLE io) |
int | io_skip (IOHANDLE io, int size) |
int | io_seek (IOHANDLE io, int offset, int origin) |
long int | io_tell (IOHANDLE io) |
long int | io_length (IOHANDLE io) |
unsigned | io_write (IOHANDLE io, const void *buffer, unsigned size) |
bool | io_write_newline (IOHANDLE io) |
int | io_close (IOHANDLE io) |
int | io_flush (IOHANDLE io) |
int | io_sync (IOHANDLE io) |
int | io_error (IOHANDLE io) |
IOHANDLE | io_stdin () |
IOHANDLE | io_stdout () |
IOHANDLE | io_stderr () |
IOHANDLE | io_current_exe () |
ASYNCIO * | aio_new (IOHANDLE io) |
void | aio_lock (ASYNCIO *aio) |
void | aio_unlock (ASYNCIO *aio) |
void | aio_write (ASYNCIO *aio, const void *buffer, unsigned size) |
void | aio_write_newline (ASYNCIO *aio) |
void | aio_write_unlocked (ASYNCIO *aio, const void *buffer, unsigned size) |
void | aio_write_newline_unlocked (ASYNCIO *aio) |
int | aio_error (ASYNCIO *aio) |
void | aio_close (ASYNCIO *aio) |
void | aio_wait (ASYNCIO *aio) |
void | aio_free (ASYNCIO *aio) |
I/O related operations.
typedef void* IOHANDLE |
Handle for input/output files/streams.
anonymous enum |
Enumerator | |
---|---|
IOFLAG_READ | Open file for reading.
|
IOFLAG_WRITE | Open file for writing.
|
IOFLAG_APPEND | Open file for appending at the end.
|
IOSEEK_START | Start seeking from the beginning of the file.
|
IOSEEK_CUR | Start seeking from the current position.
|
IOSEEK_END | Start seeking from the end of the file.
|
void aio_close | ( | ASYNCIO * | aio | ) |
Queues file closing.
aio | Handle to the file. |
int aio_error | ( | ASYNCIO * | aio | ) |
Checks whether errors have occurred during the asynchronous writing.
Call this function regularly to see if there are errors. Call this function after aio_wait to see if the process of writing to the file succeeded.
aio | Handle to the file. |
0
on success, or non-0
on error. void aio_free | ( | ASYNCIO * | aio | ) |
Frees the resources associated with the asynchronous file handle.
aio | Handle to the file. |
void aio_lock | ( | ASYNCIO * | aio | ) |
Locks the ASYNCIO
structure so it can't be written into by other threads.
aio | Handle to the file. |
Wraps a IOHANDLE for asynchronous writing.
io | Handle to the file. |
void aio_unlock | ( | ASYNCIO * | aio | ) |
Unlocks the ASYNCIO
structure after finishing the contiguous write.
aio | Handle to the file. |
void aio_wait | ( | ASYNCIO * | aio | ) |
Wait for the asynchronous operations to complete.
aio | Handle to the file. |
void aio_write | ( | ASYNCIO * | aio, |
const void * | buffer, | ||
unsigned | size | ||
) |
Queues a chunk of data for writing.
aio | Handle to the file. |
buffer | Pointer to the data that should be written. |
size | Number of bytes to write. |
void aio_write_newline | ( | ASYNCIO * | aio | ) |
Queues a newline for writing.
aio | Handle to the file. |
void aio_write_newline_unlocked | ( | ASYNCIO * | aio | ) |
void aio_write_unlocked | ( | ASYNCIO * | aio, |
const void * | buffer, | ||
unsigned | size | ||
) |
int io_close | ( | IOHANDLE | io | ) |
Closes a file.
io | Handle to the file. |
0
on success. IOHANDLE io_current_exe | ( | ) |
Returns a handle for the current executable.
int io_error | ( | IOHANDLE | io | ) |
Checks whether an error occurred during I/O with the file.
io | Handle to the file. |
0
on success, or non-0
on error. int io_flush | ( | IOHANDLE | io | ) |
Empties all buffers and writes all pending data.
io | Handle to the file. |
0
on success. long int io_length | ( | IOHANDLE | io | ) |
Gets the total length of the file. Resets cursor to the beginning.
io | Handle to the file. |
-1
on failure. IOHANDLE io_open | ( | const char * | filename, |
int | flags | ||
) |
Opens a file.
File | to open. |
flags | A set of IOFLAG flags. |
nullptr
on failure. unsigned io_read | ( | IOHANDLE | io, |
void * | buffer, | ||
unsigned | size | ||
) |
Reads data into a buffer from a file.
io | Handle to the file to read data from. |
buffer | Pointer to the buffer that will receive the data. |
size | Number of bytes to read from the file. |
void io_read_all | ( | IOHANDLE | io, |
void ** | result, | ||
unsigned * | result_len | ||
) |
Reads the rest of the file into a buffer.
io | Handle to the file to read data from. |
result | Receives the file's remaining contents. |
result_len | Receives the file's remaining length. |
char * io_read_all_str | ( | IOHANDLE | io | ) |
Reads the rest of the file into a zero-terminated buffer with no internal null bytes.
io | Handle to the file to read data from. |
nullptr
on failure.int io_seek | ( | IOHANDLE | io, |
int | offset, | ||
int | origin | ||
) |
Seeks to a specified offset in the file.
io | Handle to the file. |
offset | Offset from position to search. |
origin | Position to start searching from. |
0
on success. int io_skip | ( | IOHANDLE | io, |
int | size | ||
) |
Skips data in a file.
io | Handle to the file. |
size | Number of bytes to skip. |
IOHANDLE io_stderr | ( | ) |
Returns a handle for the standard error.
IOHANDLE io_stdin | ( | ) |
Returns a handle for the standard input.
IOHANDLE io_stdout | ( | ) |
Returns a handle for the standard output.
int io_sync | ( | IOHANDLE | io | ) |
Synchronize file changes to disk.
io | Handle to the file. |
0
on success. long int io_tell | ( | IOHANDLE | io | ) |
Gets the current position in the file.
io | Handle to the file. |
-1
on failure. unsigned io_write | ( | IOHANDLE | io, |
const void * | buffer, | ||
unsigned | size | ||
) |
Writes data from a buffer to a file.
io | Handle to the file. |
buffer | Pointer to the data that should be written. |
size | Number of bytes to write. |
bool io_write_newline | ( | IOHANDLE | io | ) |
Writes a platform dependent newline to a file.
io | Handle to the file. |
true
on success, false
on failure.