Wheefun I/O Library
0.0.5
Useful I/O Primitives.
|
File descriptor wrappers. More...
Go to the source code of this file.
Classes | |
class | wfio::FDDevice |
A Device wrapping a file descriptor. More... | |
Namespaces | |
wfio | |
The root namespace for WFIO. | |
Functions | |
WFIO_C_BEGIN WFIO_DLL struct wfio_device_t * | wfio_device_from_fd (wfio_fd_t handle, int *error) |
Wrap the device with the given file descriptor handle . More... | |
WFIO_DLL wfio_fd_t | wfio_fd_open (const char *path, const char *mode, int *error) |
Open a new file descriptor for the given path and in the specified STDIO mode mode . More... | |
WFIO_DLL wfio_fd_t | wfio_fd_openEx (const char *path, wfio_openmode_t mode, int *error) |
Open a new file descriptor for the given path and in the specified openmode mode . More... | |
WFIO_DLL void | wfio_fd_close (wfio_fd_t fd) |
Close a presently open file descriptor. More... | |
WFIO_DLL_FASTCALL size_t | wfio_fd_read (wfio_fd_t fd, void *buf, size_t len, int *error) |
Read from a file descriptor. More... | |
WFIO_DLL_FASTCALL size_t | wfio_fd_write (wfio_fd_t fd, const void *buf, size_t len, int *error) |
Write to a file descriptor. More... | |
WFIO_DLL_FASTCALL int | wfio_fd_seek (wfio_fd_t fd, wfio_off_t offset, wfio_whence_t whence, int *error) |
Seek to a position in the file descriptor's stream. More... | |
WFIO_DLL_FASTCALL wfio_off_t | wfio_fd_tell (wfio_fd_t fd, int *error) |
Determine the current stream position of this file descriptor. More... | |
WFIO_DLL_FASTCALL wfio_fd_t | wfio_fd_dup (wfio_fd_t fd, int *error) |
Duplicate a file descriptor. More... | |
WFIO_DLL_FASTCALL int | wfio_fd_vioctl (wfio_fd_t fd, int cmd, int *error, va_list va) |
Perform device-dependent I/O control on the supplied file descriptor. More... | |
WFIO_INLINE int | wfio_fd_ioctl (wfio_fd_t fd, int cmd, int *error,...) |
Perform device-dependent I/O control on the supplied file descriptor. More... | |
WFIO_DLL int | wfio_fd_setflags (wfio_fd_t fd, int flags, int *error) |
Update the device flags of the file descriptor fd . More... | |
WFIO_DLL int | wfio_fd_getflags (wfio_fd_t fd, int *error) |
Obtain the device flags corresponding to the file descriptor fd . More... | |
WFIO_DLL int | wfio_fd_truncate (wfio_fd_t fd, size_t sz, int *error) |
Resize the resource represented by the file descriptor fd to be no greater than sz . More... | |
File descriptor wrappers.
WFIO_C_BEGIN WFIO_DLL struct wfio_device_t* wfio_device_from_fd | ( | wfio_fd_t | handle, |
int * | error | ||
) |
Wrap the device with the given file descriptor handle
.
This function creates a new device which wraps around a file descriptor. It shall behave as if the wfio_fd_*
functions corresponding to each operation was used.
handle | The file handle to wrap. |
error | An optional error indicator. |
Close a presently open file descriptor.
fd | The file descriptor to close. |
WFIO_DLL_FASTCALL wfio_fd_t wfio_fd_dup | ( | wfio_fd_t | fd, |
int * | error | ||
) |
Duplicate a file descriptor.
fd | The file descriptor to duplicate. |
Obtain the device flags corresponding to the file descriptor fd
.
fd | The file descriptor to manipulate. |
flags | The device flags to set. |
error | An optional error indicator. |
WFIO_INLINE int wfio_fd_ioctl | ( | wfio_fd_t | fd, |
int | cmd, | ||
int * | error, | ||
... | |||
) |
Perform device-dependent I/O control on the supplied file descriptor.
Calling this function occurs in a purely implementation-defined manner. On UNIX systems, the behavior shall be the same as if ioctl() was called.
fd | The file descriptor to ioctl. |
cmd | The command to send to the file descriptor. |
error | An optional error indicator. |
... | Additional arguments to the ioctl. |
cmd
.Open a new file descriptor for the given path
and in the specified STDIO mode mode
.
path | The pathname to open. |
WFIO_DLL wfio_fd_t wfio_fd_openEx | ( | const char * | path, |
wfio_openmode_t | mode, | ||
int * | error | ||
) |
Open a new file descriptor for the given path
and in the specified openmode mode
.
path | The pathname to open. |
WFIO_DLL_FASTCALL size_t wfio_fd_read | ( | wfio_fd_t | fd, |
void * | buf, | ||
size_t | len, | ||
int * | error | ||
) |
Read from a file descriptor.
This function reads from a file descriptor by wrapping the host's method of doing so.
fd | The file descriptor to read. |
buf | The buffer to read into. |
len | The maximum number of bytes to read. |
error | An optional error indicator. |
The | number of bytes read on success; otherwise, WFIO_NPOS. |
WFIO_DLL_FASTCALL int wfio_fd_seek | ( | wfio_fd_t | fd, |
wfio_off_t | offset, | ||
wfio_whence_t | whence, | ||
int * | error | ||
) |
Seek to a position in the file descriptor's stream.
fd | The file descriptor to seek. |
offset | The offset relative to whence to seek to. |
whence | The origin from whence to seek. |
error | An optional error indicator. |
Update the device flags of the file descriptor fd
.
fd | The file descriptor to manipulate. |
flags | The device flags to set. |
error | An optional error indicator. |
WFIO_DLL_FASTCALL wfio_off_t wfio_fd_tell | ( | wfio_fd_t | fd, |
int * | error | ||
) |
Determine the current stream position of this file descriptor.
fd | The file descriptor to seek. |
error | An optional error indicator. |
Resize the resource represented by the file descriptor fd
to be no greater than sz
.
fd | The file descriptor to manipulate. |
sz | The desired size of the file descriptor. |
error | An optional error indicator. |
WFIO_DLL_FASTCALL int wfio_fd_vioctl | ( | wfio_fd_t | fd, |
int | cmd, | ||
int * | error, | ||
va_list | va | ||
) |
Perform device-dependent I/O control on the supplied file descriptor.
This function is like wfio_fd_ioctl()
, except that it operates on a va_list instead.
fd | The file descriptor to ioctl. |
cmd | The command to send to the file descriptor. |
error | An optional error indicator. |
va | Additional arguments to the ioctl. |
cmd
.WFIO_DLL_FASTCALL size_t wfio_fd_write | ( | wfio_fd_t | fd, |
const void * | buf, | ||
size_t | len, | ||
int * | error | ||
) |
Write to a file descriptor.
This function write from a file descriptor by wrapping the host's method of doing so.
fd | The file descriptor to write. |
buf | The buffer to write from. |
len | The maximum number of bytes to write. |
error | An optional error indicator. |
The | number of bytes read on success; otherwise, WFIO_NPOS. |