#include <fsys.h>
Public Types | |
enum | access_t { ACCESS_RDONLY, ACCESS_WRONLY, ACCESS_REWRITE, ACCESS_RDWR = ACCESS_REWRITE, ACCESS_APPEND, ACCESS_SHARED, ACCESS_DIRECTORY, ACCESS_STREAM, ACCESS_RANDOM } |
Enumerated file access modes. | |
typedef long | offset_t |
File offset type. | |
Public Member Functions | |
fsys () | |
Construct an unattached fsys descriptor. | |
fsys (const fsys &descriptor) | |
Copy (dup) an existing fsys descriptor. | |
fsys (const char *path, access_t access) | |
Create a fsys descriptor by opening an existing file or directory. | |
fsys (const char *path, access_t access, unsigned permission) | |
Create a fsys descriptor by creating a file. | |
~fsys () | |
Close and release a file descriptor. | |
fd_t | operator* () const |
Get the descriptor from the object by pointer reference. | |
operator fd_t () const | |
Get the descriptor from the object by casting reference. | |
operator bool () | |
Test if file descriptor is open. | |
bool | operator! () |
Test if file descriptor is closed. | |
void | operator= (const fsys &descriptor) |
Assign file descriptor by duplicating another descriptor. | |
void | operator= (fd_t descriptor) |
Assing file descriptor from system descriptor. | |
int | getError (void) |
Get the error number (errno) associated with the descriptor from the last error recorded. | |
fd_t | getHandle (void) |
Get the native system descriptor handle of the file descriptor. | |
void | seek (offset_t offset) |
Set the position of a file descriptor. | |
void | drop (offset_t size=0) |
Drop cached data from start of file. | |
ssize_t | read (void *buffer, size_t count) |
Read data from descriptor or scan directory. | |
ssize_t | write (const void *buffer, size_t count) |
Write data to descriptor. | |
int | stat (struct stat *buffer) |
Get status of open descriptor. | |
int | sync (void) |
Commit changes to the filesystem. | |
void | open (const char *path, access_t access) |
Open a file or directory. | |
void | assign (fd_t descriptor) |
Assign descriptor directly. | |
void | create (const char *path, access_t access, unsigned mode) |
Open a file descriptor directly. | |
void | close (void) |
Close a fsys resource. | |
Static Public Member Functions | |
static int | changeDir (const char *path) |
Set directory prefix (chdir). | |
static char * | getPrefix (char *path, size_t size) |
Get current directory prefix (pwd). | |
static int | stat (const char *path, struct stat *buffer) |
Stat a file. | |
static int | remove (const char *path) |
Remove a file. | |
static int | rename (const char *oldpath, const char *newpath) |
Rename a file. | |
static int | change (const char *path, unsigned mode) |
Change file access mode. | |
static int | access (const char *path, unsigned mode) |
Test path access. | |
static bool | isfile (const char *path) |
Test if path is a file. | |
static bool | isdir (const char *path) |
Test if path is a directory. | |
static ssize_t | read (fsys &descriptor, void *buffer, size_t count) |
Read data from file descriptor or directory. | |
static ssize_t | write (fsys &descriptor, const void *buffer, size_t count) |
write data to file descriptor. | |
static void | seek (fsys &descriptor, offset_t offset) |
Set the position of a file descriptor. | |
static void | drop (fsys &descriptor, offset_t size) |
Drop cached data from a file descriptor. | |
static void | assign (fsys &object, fd_t descriptor) |
Assign a descriptor directly. | |
static int | createDir (const char *path, unsigned mode) |
Simple direct method to create a directory. | |
static int | removeDir (const char *path) |
Simple direct method to remove a directory. | |
static void | close (fsys &descriptor) |
Close a file descriptor or directory directly. | |
static void | open (fsys &object, const char *path, access_t access) |
Open a file or directory. | |
static void | create (fsys &object, const char *path, access_t access, unsigned mode) |
create a file descriptor or directory directly. | |
static int | load (const char *path) |
Load an unmaged plugin directly. | |
static void | load (fsys &module, const char *path) |
Load a plugin into memory. | |
static void | unload (fsys &module) |
unload a specific plugin. | |
static void * | find (fsys &module, const char *symbol) |
Find symbol in loaded module. | |
Static Public Attributes | |
static const offset_t | end |
Used to mark "append" in set position operations. | |
Static Protected Member Functions | |
static int | remapError (void) |
Protected Attributes | |
fd_t | fd |
void * | ptr |
int | error |
These are based roughly on their posix equivilents. For libpth, the system calls are wrapped. The native file descriptor or handle may be used, but it is best to use "class fsys" instead because it can capture the errno of a file operation in a threadsafe and platform independent manner, including for mswindows targets.
Definition at line 60 of file fsys.h.
ucc::fsys::fsys | ( | const fsys & | descriptor | ) |
ucc::fsys::fsys | ( | const char * | path, | |
access_t | access | |||
) |
Create a fsys descriptor by opening an existing file or directory.
path | of file to open for created descriptor. | |
access | mode of file. |
ucc::fsys::fsys | ( | const char * | path, | |
access_t | access, | |||
unsigned | permission | |||
) |
Create a fsys descriptor by creating a file.
path | of file to create for descriptor. | |
access | mode of file access. | |
permission | mode of file. |
static int ucc::fsys::access | ( | const char * | path, | |
unsigned | mode | |||
) | [static] |
Test path access.
path | to test. | |
mode | to test for. |
static void ucc::fsys::assign | ( | fsys & | object, | |
fd_t | descriptor | |||
) | [inline, static] |
void ucc::fsys::assign | ( | fd_t | descriptor | ) | [inline] |
static int ucc::fsys::change | ( | const char * | path, | |
unsigned | mode | |||
) | [static] |
Change file access mode.
path | to change. | |
mode | to assign. |
static int ucc::fsys::changeDir | ( | const char * | path | ) | [static] |
Set directory prefix (chdir).
path | to change to. |
static void ucc::fsys::close | ( | fsys & | descriptor | ) | [inline, static] |
void ucc::fsys::create | ( | const char * | path, | |
access_t | access, | |||
unsigned | mode | |||
) |
Open a file descriptor directly.
path | of file to create. | |
access | mode of descriptor. | |
mode | of file if created. |
static int ucc::fsys::createDir | ( | const char * | path, | |
unsigned | mode | |||
) | [static] |
Simple direct method to create a directory.
path | of directory to create. | |
mode | of directory. |
void ucc::fsys::drop | ( | offset_t | size = 0 |
) |
Drop cached data from start of file.
size | of region to drop or until end of file. |
static void* ucc::fsys::find | ( | fsys & | module, | |
const char * | symbol | |||
) | [static] |
Find symbol in loaded module.
module | to search. | |
symbol | to search for. |
int ucc::fsys::getError | ( | void | ) | [inline] |
fd_t ucc::fsys::getHandle | ( | void | ) | [inline] |
static char* ucc::fsys::getPrefix | ( | char * | path, | |
size_t | size | |||
) | [static] |
Get current directory prefix (pwd).
path | to save directory into. | |
size | of path we can save. |
static bool ucc::fsys::isdir | ( | const char * | path | ) | [static] |
Test if path is a directory.
path | to test. |
static bool ucc::fsys::isfile | ( | const char * | path | ) | [static] |
Test if path is a file.
path | to test. |
static void ucc::fsys::load | ( | fsys & | module, | |
const char * | path | |||
) | [static] |
Load a plugin into memory.
module | for management. | |
path | to plugin. |
static int ucc::fsys::load | ( | const char * | path | ) | [static] |
Load an unmaged plugin directly.
path | to plugin. |
void ucc::fsys::open | ( | const char * | path, | |
access_t | access | |||
) |
Open a file or directory.
path | of file to open. | |
access | mode of descriptor. |
ucc::fsys::operator bool | ( | ) | [inline] |
ucc::fsys::operator fd_t | ( | ) | const [inline] |
bool ucc::fsys::operator! | ( | ) | [inline] |
fd_t ucc::fsys::operator* | ( | ) | const [inline] |
void ucc::fsys::operator= | ( | fd_t | descriptor | ) |
Assing file descriptor from system descriptor.
descriptor | to dup from. |
void ucc::fsys::operator= | ( | const fsys & | descriptor | ) |
Assign file descriptor by duplicating another descriptor.
descriptor | to dup from. |
static ssize_t ucc::fsys::read | ( | fsys & | descriptor, | |
void * | buffer, | |||
size_t | count | |||
) | [inline, static] |
ssize_t ucc::fsys::read | ( | void * | buffer, | |
size_t | count | |||
) |
Read data from descriptor or scan directory.
buffer | to read into. | |
count | of bytes to read. |
static int ucc::fsys::remove | ( | const char * | path | ) | [static] |
Remove a file.
path | of file. |
static int ucc::fsys::removeDir | ( | const char * | path | ) | [static] |
Simple direct method to remove a directory.
path | to remove. |
static int ucc::fsys::rename | ( | const char * | oldpath, | |
const char * | newpath | |||
) | [static] |
Rename a file.
oldpath | to rename from. | |
newpath | to rename to. |
void ucc::fsys::seek | ( | offset_t | offset | ) |
Set the position of a file descriptor.
offset | from start of file or "end" to append. |
static int ucc::fsys::stat | ( | const char * | path, | |
struct stat * | buffer | |||
) | [static] |
Stat a file.
path | of file to stat. | |
buffer | to save stat info. |
int ucc::fsys::stat | ( | struct stat * | buffer | ) |
Get status of open descriptor.
buffer | to save status info in. |
int ucc::fsys::sync | ( | void | ) |
Commit changes to the filesystem.
static void ucc::fsys::unload | ( | fsys & | module | ) | [static] |
unload a specific plugin.
module | to unload |
static ssize_t ucc::fsys::write | ( | fsys & | descriptor, | |
const void * | buffer, | |||
size_t | count | |||
) | [inline, static] |
ssize_t ucc::fsys::write | ( | const void * | buffer, | |
size_t | count | |||
) |
Write data to descriptor.
buffer | to write from. | |
count | of bytes to write. |