Wheefun I/O Library  0.0.5
Useful I/O Primitives.
Classes | Namespaces | Functions
file.h File Reference

Filesystem interaction. More...

#include <wfio/type.h>

Go to the source code of this file.

Classes

class  wfio::FileDevice
 A Device wrapping a file stream. More...
 

Namespaces

 wfio
 The root namespace for WFIO.
 

Functions

WFIO_C_BEGIN WFIO_DLL struct wfio_device_twfio_device_open_file (const char *path, const char *mode, int *error)
 Open a file located at path. More...
 
WFIO_DLL struct wfio_device_twfio_device_open_fileEx (const char *path, wfio_openmode_t mode, int *error)
 Open a file located at path using extended syntax. More...
 
WFIO_DLL wfio_openmode_t wfio_stdio_parseMode (const char *mode, int *error)
 Obtain an openmode for the specified STDIO mode string. More...
 
WFIO_DLL const char * wfio_stdio_deriveMode (wfio_openmode_t mode, int *error)
 Obtain an STDIO mode string for the provided mode. More...
 
WFIO_DLL_FASTCALL const char * wfio_file_cwd (char *path, size_t len, int *error)
 Obtain the path to the current working directory. More...
 
WFIO_DLL_FASTCALL int wfio_file_cd (const char *path, int *error)
 Change the current working directory to path. More...
 
WFIO_DLL_FASTCALL int wfio_file_unlink (const char *path, int *error)
 Remove path from the filesystem. More...
 
WFIO_DLL_FASTCALL int wfio_file_exists (const char *path, int *error)
 Determine if path exists. More...
 
WFIO_DLL_FASTCALL int wfio_file_rename (const char *src, const char *dest, int *error)
 Rename the path supplied by src to dest. More...
 
WFIO_DLL int wfio_file_truncate (const char *path, size_t sz, int *error)
 Trim the file at path to the specified sz. More...
 

Detailed Description

Filesystem interaction.

Author
Phillip Kilgore
Since
0.0.1
Note
This file may include <stdio.h>.

Function Documentation

◆ wfio_device_open_file()

WFIO_C_BEGIN WFIO_DLL struct wfio_device_t* wfio_device_open_file ( const char *  path,
const char *  mode,
int *  error 
)

Open a file located at path.

Parameters
pathThe path to attempt to open.
modeThe STDIO mode to open the file with.
errorAn optional error indicator.

◆ wfio_device_open_fileEx()

WFIO_DLL struct wfio_device_t* wfio_device_open_fileEx ( const char *  path,
wfio_openmode_t  mode,
int *  error 
)

Open a file located at path using extended syntax.

Parameters
pathThe path to attempt to open.
modeThe openmode to open the file with.
errorAn optional error indicator.

◆ wfio_file_cd()

WFIO_DLL_FASTCALL int wfio_file_cd ( const char *  path,
int *  error 
)

Change the current working directory to path.

Parameters
pathThe path to change to.
errorAn optional error indicator.
Returns
Nonzero if successful; otherwise, zero.

◆ wfio_file_cwd()

WFIO_DLL_FASTCALL const char* wfio_file_cwd ( char *  path,
size_t  len,
int *  error 
)

Obtain the path to the current working directory.

Parameters
pathThe buffer to store the pathname in.
lenThe size of the buffer in bytes.
errorAn optional error indicator.
Thecurrent pathname on success; otherwise, NULL.

◆ wfio_file_exists()

WFIO_DLL_FASTCALL int wfio_file_exists ( const char *  path,
int *  error 
)

Determine if path exists.

Parameters
pathThe path to test.
errorAn optional error indicator.
Returns
Nonzero if the path exists; otherwise, zero.

◆ wfio_file_rename()

WFIO_DLL_FASTCALL int wfio_file_rename ( const char *  src,
const char *  dest,
int *  error 
)

Rename the path supplied by src to dest.

Parameters
srcThe path to rename.
destWhat to rename the path to.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

◆ wfio_file_truncate()

WFIO_DLL int wfio_file_truncate ( const char *  path,
size_t  sz,
int *  error 
)

Trim the file at path to the specified sz.

Parameters
srcThe path to truncate.
szThe requested file size.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

◆ wfio_file_unlink()

WFIO_DLL_FASTCALL int wfio_file_unlink ( const char *  path,
int *  error 
)

Remove path from the filesystem.

Parameters
pathThe path to unlink.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

◆ wfio_stdio_deriveMode()

WFIO_DLL const char* wfio_stdio_deriveMode ( wfio_openmode_t  mode,
int *  error 
)

Obtain an STDIO mode string for the provided mode.

Parameters
modeThe openmode to look up.
errorAn optional error indicator.
Returns
The parsed openmode.

◆ wfio_stdio_parseMode()

WFIO_DLL wfio_openmode_t wfio_stdio_parseMode ( const char *  mode,
int *  error 
)

Obtain an openmode for the specified STDIO mode string.

Parameters
modeThe mode string to parse.
errorAn optional error indicator.
Returns
The parsed openmode.