Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Some very basic definitions and functions.
Enhanced file and directory operations ... | |
size_t | Write (int fd, const void *buf, size_t count) |
Similar to POSIX write(), but writes all 'count' bytes as possible. More... | |
size_t | Read (int fd, void *buf, size_t count) |
Similar to POSIX read(), but reads all 'count' bytes as possible. More... | |
bool | MakeDir (const char *relOrAbsPath, bool setHome2lGroup=true) |
Create a directory (and all its parents as necessary). More... | |
bool | UnlinkTree (const char *relOrAbsPath, const char *skipPattern=NULL) |
Unlink (remove) a directory with all its decendants. More... | |
bool | ReadDir (const char *relOrAbsPath, class CKeySet *ret) |
Read a directory into a CKeySet object. More... | |
size_t Write | ( | int | fd, |
const void * | buf, | ||
size_t | count | ||
) |
Similar to POSIX write(), but writes all 'count' bytes as possible.
This function repeatedly calls write(2) until 'count' bytes have been written. On error, the actual number of bytes written is returned (which is less than 'count'), and 'errno' is set accordingly. If the file is opened in non-blocking mode, the function does not wait, but writes as many bytes as possible immediately and sets/leaves 'errno == EAGAIN'.
size_t Read | ( | int | fd, |
void * | buf, | ||
size_t | count | ||
) |
Similar to POSIX read(), but reads all 'count' bytes as possible.
This function repeatedly calls read(2) until 'count' bytes have been read. On error or end-of-file, the actual number of bytes read is returned (which is less than 'count'), and 'errno' is set accordingly. In the case of an end-of-file condition, 'errno' is set to 0. If the file is opened in non-blocking mode, the function does not wait, but returns the bytes available immediately and sets/leaves 'errno == EAGAIN'.
bool MakeDir | ( | const char * | relOrAbsPath, |
bool | setHome2lGroup = true |
||
) |
Create a directory (and all its parents as necessary).
If the argument is a symbolic links, the target directory (tree) is created if it does not yet exist.
relOrAbsPath | is either an absolute path or a path relative to HOME2L_ROOT and must identify a directory. |
setHome2lGroup | selects to set the directory group ownerships to HOME2L_USER, if possible. |
bool UnlinkTree | ( | const char * | relOrAbsPath, |
const char * | skipPattern = NULL |
||
) |
Unlink (remove) a directory with all its decendants.
relOrAbsPath | is either an absolute path or a path relative to HOME2L_ROOT and must identify a directory. |
skipPattern | identifies portions not to be unlinked. Presently, only a whitespace-separated list of items of the form "\<name\>" is supported, which means that, if relOrAbsPath is a directory, its top-level directory <name> is skipped. Further variants may be implemented in the future. |
bool ReadDir | ( | const char * | relOrAbsPath, |
class CKeySet * | ret | ||
) |