File I/O - ALURE

# File I/O

Summary

File I/O |
Functions |
alureSetIOCallbacks | Provides callbacks for alternative methods to handle file I/O.

### Functions

### alureSetIOCallbacks

> ALURE_API ALboolean ALURE_APIENTRY alureSetIOCallbacks(
> | void | * | (*open)(const char *filename, ALuint mode),
> | void |  | (*close)(void *handle),
> | ALsizei |  | (*read)(void *handle, ALubyte *buf, ALuint bytes),
> | ALsizei |  | (*write)(void *handle, const ALubyte *buf, ALuint bytes),
> | alureInt64 |  | (*seek)(void *handle, alureInt64 offset, int whence)
> )

Provides callbacks for alternative methods to handle file I/O. Passing NULL for all callbacks is a valid way to revert to normal I/O, otherwise they must all be specified. Changing the callbacks will not affect open files (they will continue using the callbacks that were set at the time they were opened).

#### Parameters

open | This callback is called to open the named file. The given mode is the access rights the open file should have. Currently, this will always be 0 for read-only (applications should check this to make sure, as future versions may pass other values for other modes). Upon success, a non-NULL handle must be returned which will be used as a unique identifier for the file.
close | This callback is called to close an opened file handle. The handle will no longer be used after this function.
read | This callback is called when data needs to be read from the given handle. Up to the given number of bytes should be copied into ‘buf’ and the number of bytes actually copied should be returned. Returning 0 means the end of the file has been reached (so non-blocking I/O methods should ensure at least 1 byte gets read), and negative indicates an error.
write | This callback is called when data needs to be written to the given handle. Up to the given number of bytes should be copied from ‘buf’ and the number of bytes actually copied should be returned. A return value of 0 means no more data can be written (so non-blocking I/O methods should ensure at least 1 byte gets written), and negative indicates an error.
seek | This callback is called to reposition the offset of the file handle. The given offset is interpreted according to ‘whence’, which may be SEEK_SET (absolute position from the start of the file), SEEK_CUR (relative position from the current offset), or SEEK_END (absolute position from the end of the file), as defined by standard C. The new offset from the beginning of the file should be returned. If the file cannot seek, such as when using a FIFO, -1 should be returned.

#### Returns

AL_FALSE on error.

Version Added: 1.1

> ALURE_API ALboolean ALURE_APIENTRY alureSetIOCallbacks(
> | void | * | (*open)(const char *filename, ALuint mode),
> | void |  | (*close)(void *handle),
> | ALsizei |  | (*read)(void *handle, ALubyte *buf, ALuint bytes),
> | ALsizei |  | (*write)(void *handle, const ALubyte *buf, ALuint bytes),
> | alureInt64 |  | (*seek)(void *handle, alureInt64 offset, int whence)
> )

Provides callbacks for alternative methods to handle file I/O.
Close