Rudiments
|
Inherits filedescriptor.
Inherited by device, link, and shmfile.
Public Member Functions | |
file () | |
file (const file &f) | |
file & | operator= (const file &f) |
virtual | ~file () |
bool | open (const char *name, int32_t flags) |
bool | open (const char *name, int32_t flags, mode_t perms) |
bool | create (const char *name, mode_t perms) |
ssize_t | create (const char *name, mode_t perms, uint16_t number) |
ssize_t | create (const char *name, mode_t perms, unsigned long number) |
ssize_t | create (const char *name, mode_t perms, float number) |
ssize_t | create (const char *name, mode_t perms, double number) |
ssize_t | create (const char *name, mode_t perms, char number) |
ssize_t | create (const char *name, mode_t perms, const char *string) |
ssize_t | create (const char *name, mode_t perms, const char *string, size_t size) |
ssize_t | create (const char *name, mode_t perms, const void *data, size_t size) |
char * | getContents () |
ssize_t | getContents (unsigned char *buffer, size_t buffersize) |
bool | truncate () const |
bool | truncate (off64_t length) const |
off64_t | getCurrentPosition () const |
off64_t | setPositionRelativeToBeginning (off64_t offset) const |
off64_t | setPositionRelativeToCurrent (off64_t offset) const |
off64_t | setPositionRelativeToEnd (off64_t offset) const |
bool | tryLockFile (int16_t type) const |
bool | lockFile (int16_t type) const |
bool | checkLockFile (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockFile () const |
bool | tryLockRegion (int16_t type, off64_t start, off64_t len) const |
bool | lockRegion (int16_t type, off64_t start, off64_t len) const |
bool | checkLockRegion (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockRegion (off64_t start, off64_t len) const |
bool | tryLockFromCurrent (int16_t type, off64_t len) const |
bool | tryLockFromCurrent (int16_t type, off64_t start, off64_t len) const |
bool | lockFromCurrent (int16_t type, off64_t len) const |
bool | lockFromCurrent (int16_t type, off64_t start, off64_t len) const |
bool | checkLockFromCurrent (int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | checkLockFromCurrent (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockFromCurrent (off64_t len) const |
bool | unlockFromCurrent (off64_t start, off64_t len) const |
bool | tryLockFromEnd (int16_t type, off64_t len) const |
bool | tryLockFromEnd (int16_t type, off64_t start, off64_t len) const |
bool | lockFromEnd (int16_t type, off64_t len) const |
bool | lockFromEnd (int16_t type, off64_t start, off64_t len) const |
bool | checkLockFromEnd (int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | checkLockFromEnd (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockFromEnd (off64_t len) const |
bool | unlockFromEnd (off64_t start, off64_t len) const |
bool | tryLockRemainder (int16_t type, off64_t start) const |
bool | lockRemainder (int16_t type, off64_t start) const |
bool | checkLockRemainder (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockRemainder (off64_t start) const |
bool | tryLockRemainderFromCurrent (int16_t type) const |
bool | tryLockRemainderFromCurrent (int16_t type, off64_t start) const |
bool | lockRemainderFromCurrent (int16_t type) const |
bool | lockRemainderFromCurrent (int16_t type, off64_t start) const |
bool | checkLockRemainderFromCurrent (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | checkLockRemainderFromCurrent (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockRemainderFromCurrent () const |
bool | unlockRemainderFromCurrent (off64_t start) const |
bool | tryLockRemainderFromEnd (int16_t type) const |
bool | tryLockRemainderFromEnd (int16_t type, off64_t start) const |
bool | lockRemainderFromEnd (int16_t type) const |
bool | lockRemainderFromEnd (int16_t type, off64_t start) const |
bool | checkLockRemainderFromEnd (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | checkLockRemainderFromEnd (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen) const |
bool | unlockRemainderFromEnd () const |
bool | unlockRemainderFromEnd (off64_t start) const |
bool | sequentialAccess (off64_t start, size_t len) const |
bool | randomAccess (off64_t start, size_t len) const |
bool | onlyOnce (off64_t start, size_t len) const |
bool | willNeed (off64_t start, size_t len) const |
bool | wontNeed (off64_t start, size_t len) const |
bool | normalAccess (off64_t start, size_t len) const |
bool | reserve (off64_t start, size_t len) const |
bool | sync () const |
bool | dataSync () const |
void | dontGetCurrentPropertiesOnOpen () |
void | getCurrentPropertiesOnOpen () |
bool | getCurrentProperties () |
mode_t | getPermissions () const |
uid_t | getOwnerUserId () const |
gid_t | getOwnerGroupId () const |
off64_t | getSize () const |
blksize_t | getBlockSize () const |
blkcnt_t | getBlockCount () const |
int32_t | isSocket () const |
int32_t | isSymbolicLink () const |
int32_t | isRegularFile () const |
int32_t | isBlockDevice () const |
int32_t | isDirectory () const |
int32_t | isCharacterDevice () const |
int32_t | isFifo () const |
time_t | getLastAccessTime () const |
time_t | getLastModificationTime () const |
time_t | getLastChangeTime () const |
dev_t | getDevice () const |
dev_t | getDeviceType () const |
ino_t | getInode () const |
nlink_t | getNumberOfHardLinks () const |
bool | changeOwner (const char *newuser, const char *newgroup) const |
bool | changeOwner (uid_t uid, gid_t gid) const |
bool | changeOwnerUser (const char *newuser) const |
bool | changeOwnerUser (uid_t uid) const |
bool | changeOwnerGroup (const char *newgroup) const |
bool | changeOwnerGroup (gid_t gid) const |
bool | canChangeOwner () const |
long | maxLinks () const |
const char *const | listAttributes () const |
bool | getAttribute (const char *name, uint16_t *number) const |
bool | getAttribute (const char *name, unsigned long *number) const |
bool | getAttribute (const char *name, int16_t *number) const |
bool | getAttribute (const char *name, long *number) const |
bool | getAttribute (const char *name, float *number) const |
bool | getAttribute (const char *name, double *number) const |
bool | getAttribute (const char *name, unsigned char *character) const |
bool | getAttribute (const char *name, char *character) const |
bool | getAttribute (const char *name, bool *value) const |
bool | getAttribute (const char *name, unsigned char **string) const |
bool | getAttribute (const char *name, char **string) const |
bool | getAttribute (const char *name, unsigned char **string, size_t *size) const |
bool | getAttribute (const char *name, char **string, size_t *size) const |
bool | getAttribute (const char *name, void **buffer, size_t *size) const |
bool | createAttribute (const char *name, uint16_t number) const |
bool | createAttribute (const char *name, unsigned long number) const |
bool | createAttribute (const char *name, int16_t number) const |
bool | createAttribute (const char *name, long number) const |
bool | createAttribute (const char *name, float number) const |
bool | createAttribute (const char *name, double number) const |
bool | createAttribute (const char *name, unsigned char character) const |
bool | createAttribute (const char *name, char character) const |
bool | createAttribute (const char *name, bool value) const |
bool | createAttribute (const char *name, const unsigned char *string) const |
bool | createAttribute (const char *name, const char *string) const |
bool | createAttribute (const char *name, const unsigned char *string, size_t size) const |
bool | createAttribute (const char *name, const char *string, size_t size) const |
bool | createAttribute (const char *name, const void *buffer, size_t size) const |
bool | replaceAttribute (const char *name, uint16_t number) const |
bool | replaceAttribute (const char *name, unsigned long number) const |
bool | replaceAttribute (const char *name, int16_t number) const |
bool | replaceAttribute (const char *name, long number) const |
bool | replaceAttribute (const char *name, float number) const |
bool | replaceAttribute (const char *name, double number) const |
bool | replaceAttribute (const char *name, unsigned char character) const |
bool | replaceAttribute (const char *name, char character) const |
bool | replaceAttribute (const char *name, bool value) const |
bool | replaceAttribute (const char *name, const unsigned char *string) const |
bool | replaceAttribute (const char *name, const char *string) const |
bool | replaceAttribute (const char *name, const unsigned char *string, size_t size) const |
bool | replaceAttribute (const char *name, const char *string, size_t size) const |
bool | replaceAttribute (const char *name, const void *buffer, size_t size) const |
bool | setAttribute (const char *name, uint16_t number) const |
bool | setAttribute (const char *name, unsigned long number) const |
bool | setAttribute (const char *name, int16_t number) const |
bool | setAttribute (const char *name, long number) const |
bool | setAttribute (const char *name, float number) const |
bool | setAttribute (const char *name, double number) const |
bool | setAttribute (const char *name, unsigned char character) const |
bool | setAttribute (const char *name, char character) const |
bool | setAttribute (const char *name, bool value) const |
bool | setAttribute (const char *name, const unsigned char *string) const |
bool | setAttribute (const char *name, const char *string) const |
bool | setAttribute (const char *name, const unsigned char *string, size_t size) const |
bool | setAttribute (const char *name, const char *string, size_t size) const |
bool | setAttribute (const char *name, const void *buffer, size_t size) const |
bool | removeAttribute (const char *name) const |
void * | getInternalFileStatisticsStructure () |
Static Public Member Functions | |
static bool | createFile (const char *name, mode_t perms) |
static ssize_t | createFile (const char *name, mode_t perms, uint16_t number) |
static ssize_t | createFile (const char *name, mode_t perms, unsigned long number) |
static ssize_t | createFile (const char *name, mode_t perms, float number) |
static ssize_t | createFile (const char *name, mode_t perms, double number) |
static ssize_t | createFile (const char *name, mode_t perms, char number) |
static ssize_t | createFile (const char *name, mode_t perms, const char *string) |
static ssize_t | createFile (const char *name, mode_t perms, const char *string, size_t size) |
static ssize_t | createFile (const char *name, mode_t perms, const void *data, size_t size) |
static bool | createFifo (const char *filename, mode_t perms) |
static bool | createPipe (filedescriptor *readfd, filedescriptor *writefd) |
static int32_t | createTemporaryFile (char *templatefilename) |
static bool | createHardLink (const char *oldpath, const char *newpath) |
static bool | createSymbolicLink (const char *oldpath, const char *newpath) |
static char * | resolveSymbolicLink (const char *filename) |
static bool | rename (const char *oldpath, const char *newpath) |
static bool | remove (const char *filename) |
static bool | truncate (const char *filename) |
static bool | truncate (const char *filename, off64_t length) |
static char * | getContents (const char *name) |
static ssize_t | getContents (const char *name, unsigned char *buffer, size_t buffersize) |
static bool | exists (const char *filename) |
static bool | readable (const char *filename) |
static bool | writeable (const char *filename) |
static bool | executable (const char *filename) |
static bool | accessible (const char *filename, int32_t mode) |
static bool | getPermissions (const char *filename, mode_t *perms) |
static bool | getOwnerUserId (const char *filename, uid_t *uid) |
static bool | getOwnerGroupId (const char *filename, gid_t *gid) |
static bool | getSize (const char *filename, off64_t *size) |
static bool | getBlockSize (const char *filename, blksize_t *size) |
static bool | getBlockCount (const char *filename, blkcnt_t *blocks) |
static int32_t | isSocket (const char *filename) |
static int32_t | isSymbolicLink (const char *filename) |
static int32_t | isRegularFile (const char *filename) |
static int32_t | isBlockDevice (const char *filename) |
static int32_t | isDirectory (const char *filename) |
static int32_t | isCharacterDevice (const char *filename) |
static int32_t | isFifo (const char *filename) |
static bool | getLastAccessTime (const char *filename, time_t *atime) |
static bool | getLastModificationTime (const char *filename, time_t *mtime) |
static bool | getLastChangeTime (const char *filename, time_t *ctime) |
static bool | getDevice (const char *filename, dev_t *dev) |
static bool | getDeviceType (const char *filename, dev_t *devtype) |
static bool | getInode (const char *filename, ino_t *inode) |
static bool | getNumberOfHardLinks (const char *filename, nlink_t *nlink) |
static bool | changeOwner (const char *filename, const char *newuser, const char *newgroup) |
static bool | changeOwner (const char *filename, uid_t uid, gid_t gid) |
static bool | changeOwnerUser (const char *filename, const char *newuser) |
static bool | changeOwnerUser (const char *filename, uid_t uid) |
static bool | changeOwnerGroup (const char *filename, const char *newgroup) |
static bool | changeOwnerGroup (const char *filename, gid_t gid) |
static bool | canChangeOwner (const char *filename) |
static bool | setLastAccessTime (const char *filename, time_t lastaccesstime) |
static bool | setLastModificationTime (const char *filename, time_t lastmodtime) |
static bool | setLastAccessAndModificationTimes (const char *filename, time_t lastaccesstime, time_t lastmodtime) |
static bool | setLastAccessAndModificationTimes (const char *filename) |
static char * | dirname (const char *filename) |
static char * | basename (const char *filename) |
static char * | basename (const char *filename, const char *suffix) |
static key_t | generateKey (const char *filename, int32_t id) |
static long | maxLinks (const char *filename) |
The file class provides methods for interacting with files and for discovering the properties associated with a file such as permissions, ownership, size, etc.
Many of the static methods are just provided for convenience. Use them if you need to get a a single property or perform a single operation.
If you need to get multiple properties or perform multiple operations, create an instance of the class, call open(), then use the non-static methods.
file::file | ( | ) |
Creates an instance of the file class.
file::file | ( | const file & | f | ) |
Creates an instance of the file class that is a copy of "f".
virtual file::~file | ( | ) | [virtual] |
Deletes this instance of the file class.
static bool file::accessible | ( | const char * | filename, |
int32_t | mode | ||
) | [static] |
Checks to see if "filename" exists, is readable, is writeable and/or is executable by the user, based on the value of "mode". Mode should be an or'ed combination of F_OK (exists), R_OK (readable), W_OK (writable) and X_OK (executable) flags.
Returns true if the file meets the conditions set by the mode and false otherwise.
static char* file::basename | ( | const char * | filename | ) | [static] |
Returns the non-directory portion of "filename". This method allocates a buffer internally and returns it. The calling program must deallocate the buffer.
static char* file::basename | ( | const char * | filename, |
const char * | suffix | ||
) | [static] |
Returns the non-directory portion of "filename", truncating "suffix". This method allocates a buffer internally and returns it. The calling program must deallocate the buffer.
bool file::canChangeOwner | ( | ) | const |
Returns true if any of the changeOwner() methods are allowed on "filename" and false otherwise.
static bool file::canChangeOwner | ( | const char * | filename | ) | [static] |
Returns true if any of the changeOwner methods are allowed on "filename" and false otherwise.
static bool file::changeOwner | ( | const char * | filename, |
uid_t | uid, | ||
gid_t | gid | ||
) | [static] |
Changes the user and/or group that owns the file. Returns true on success and false on failure.
bool file::changeOwner | ( | const char * | newuser, |
const char * | newgroup | ||
) | const |
Changes the user and/or group that owns the file. Returns true on success and false on failure.
bool file::changeOwner | ( | uid_t | uid, |
gid_t | gid | ||
) | const |
Changes the user that owns the file. Returns true on success and false on failure.
static bool file::changeOwner | ( | const char * | filename, |
const char * | newuser, | ||
const char * | newgroup | ||
) | [static] |
Changes the user and/or group that owns the file. Returns true on success and false on failure.
bool file::changeOwnerGroup | ( | const char * | newgroup | ) | const |
Changes the group that owns the file. Returns true on success and false on failure.
bool file::changeOwnerGroup | ( | gid_t | gid | ) | const |
Changes the group that owns the file. Returns true on success and false on failure.
static bool file::changeOwnerGroup | ( | const char * | filename, |
const char * | newgroup | ||
) | [static] |
Changes the group that owns the file. Returns true on success and false on failure.
static bool file::changeOwnerGroup | ( | const char * | filename, |
gid_t | gid | ||
) | [static] |
Changes the group that owns the file. Returns true on success and false on failure.
bool file::changeOwnerUser | ( | const char * | newuser | ) | const |
Changes the user that owns the file. Returns true on success and false on failure.
bool file::changeOwnerUser | ( | uid_t | uid | ) | const |
Changes the user that owns the file. Returns true on success and false on failure.
static bool file::changeOwnerUser | ( | const char * | filename, |
uid_t | uid | ||
) | [static] |
Changes the user that owns the file. Returns true on success and false on failure.
static bool file::changeOwnerUser | ( | const char * | filename, |
const char * | newuser | ||
) | [static] |
Changes the user that owns the file. Returns true on success and false on failure.
bool file::checkLockFile | ( | int16_t | type, |
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the entire file can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockFromCurrent | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if "len" bytes of the file starting at the current position in the file plus "start" bytes can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockFromCurrent | ( | int16_t | type, |
off64_t | len, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if "len" bytes of the file starting at the current position in the file can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockFromEnd | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if "len" bytes of the file starting at the end of the file plus "start" bytes can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockFromEnd | ( | int16_t | type, |
off64_t | len, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if "len" bytes of the file starting at the end of the file can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRegion | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if "len" bytes of the file starting at position "start" (relative to the beginning of the file) can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRemainder | ( | int16_t | type, |
off64_t | start, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the remainder of the file starting at position "start" (relative to the beginning of the file) can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRemainderFromCurrent | ( | int16_t | type, |
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the remainder of the file starting at the current position can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRemainderFromCurrent | ( | int16_t | type, |
off64_t | start, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the remainder of the file starting at the current position plus "start" bytes can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRemainderFromEnd | ( | int16_t | type, |
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the remainder of the file starting at the end can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::checkLockRemainderFromEnd | ( | int16_t | type, |
off64_t | start, | ||
int16_t * | conftype, | ||
int16_t * | confwhence, | ||
off64_t * | confstart, | ||
off64_t * | conflen | ||
) | const |
Checks to see if the remainder of the file starting at the end plus "start" bytes can be locked or not using the specified lock "type" (F_RDLCK or F_WRLCK) but does not actually attempt to lock the file. Returns true if the lock can be established immediately or false otherwise.
If the lock cannot be established then the "conf" parameters will be populated with the details about a conflicting lock which would prevent the file from being locked. "conftype" will contain the type of the lock (F_RDLCK or F_WRLCK) "confwhence" will contain the offset type of the lock (SEEK_SET, SEEK_CUR or SEEK_END), "confstart" will contain the starting offset for the lock and "conflen" will contain the number of bytes that are locked.
bool file::create | ( | const char * | name, |
mode_t | perms | ||
) |
Creates the file "name" with permissions "perms". If the file already exists, it will be truncated. Returns true on success and false on failure.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
double | number | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "number". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
char | number | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "number". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
uint16_t | number | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "number". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
const char * | string | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "string". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
const char * | string, | ||
size_t | size | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to the first "size" bytes of "string". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated. Returns the number of bytes written or -1 on error.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
const void * | data, | ||
size_t | size | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to the first "size" bytes of "data". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated. Returns the number of bytes written or -1 on error.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
unsigned long | number | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "number". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
ssize_t file::create | ( | const char * | name, |
mode_t | perms, | ||
float | number | ||
) |
Creates the file "name" with permissions "perms" and sets the initial contents to "number". Returns the number of bytes written or -1 on error. If the file already exists, it will be truncated.
bool file::createAttribute | ( | const char * | name, |
bool | value | ||
) | const |
Creates a new attribute named "name" with value "value". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
const unsigned char * | string | ||
) | const |
Creates a new attribute named "name" with value "string". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
const char * | string | ||
) | const |
Creates a new attribute named "name" with value "string". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
const unsigned char * | string, | ||
size_t | size | ||
) | const |
Creates a new attribute named "name" with a value of the first "size" bytes of "string". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
const char * | string, | ||
size_t | size | ||
) | const |
Creates a new attribute named "name" with a value of the first "size" bytes of "string". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
const void * | buffer, | ||
size_t | size | ||
) | const |
Creates a new attribute named "name" with a value of the first "size" bytes of "buffer". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
uint16_t | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
unsigned long | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
int16_t | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
long | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
float | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
double | number | ||
) | const |
Creates a new attribute named "name" with value "number". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
unsigned char | character | ||
) | const |
Creates a new attribute named "name" with value "character". Returns true on success and false on failure.
bool file::createAttribute | ( | const char * | name, |
char | character | ||
) | const |
Creates a new attribute named "name" with value "character". Returns true on success and false on failure.
static bool file::createFifo | ( | const char * | filename, |
mode_t | perms | ||
) | [static] |
Creates a fifo called "filename" with permissions "perms". Returns true on success and false on failure.
static bool file::createFile | ( | const char * | name, |
mode_t | perms | ||
) | [static] |
Create a file named "name" with permissions "perms". If the file already exists, it will be truncated. Returns true on success and false on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
uint16_t | number | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "number". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
unsigned long | number | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "number". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
float | number | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "number". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
double | number | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "number". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
char | number | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "number". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
const char * | string | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to "string". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
const char * | string, | ||
size_t | size | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to the first "size" bytes of "string". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static ssize_t file::createFile | ( | const char * | name, |
mode_t | perms, | ||
const void * | data, | ||
size_t | size | ||
) | [static] |
Create a file named "name" with permissions "perms" and sets the initial contents of the file to the first "size" bytes of "data". If the file already exists, it will be truncated. Returns the number of bytes written on success or -1 on failure.
static bool file::createHardLink | ( | const char * | oldpath, |
const char * | newpath | ||
) | [static] |
Creates a hard link between "oldpath" and "newpath". Returns true on success and false on failure.
static bool file::createPipe | ( | filedescriptor * | readfd, |
filedescriptor * | writefd | ||
) | [static] |
Creates a pipe and sets "readfd" to the read side and "writefd" to the write side.
static bool file::createSymbolicLink | ( | const char * | oldpath, |
const char * | newpath | ||
) | [static] |
Creates a symbolic link between "oldpath" and "newpath". Returns true on success and false on failure.
static int32_t file::createTemporaryFile | ( | char * | templatefilename | ) | [static] |
Creates a temporary file using "templatefilename" as a template. The last 6 characters of "templatefilename" must be XXXXXX and "templatefilename" will be modified to contain the name of the file that was actually created.
Opens and returns the file descriptor handle of the file on success and -1 on failure.
bool file::dataSync | ( | ) | const |
On most filesystems, changes to files are often cached in system ram, this methods causes those changes to be immediately copied to the storage medium that the file resides on.
This method differs from sync() in that it does not wait until file metadata such as last-access or last-modification times to be written before it returns.
Returns true on success and false on failure.
Note that if a hard disk has on-board write cache enabled, this method only assures that the changes has been copied into the disk's write cache, not necessarily to the disk itself.
static char* file::dirname | ( | const char * | filename | ) | [static] |
Returns the directory portion of "filename". This method allocates a buffer internally and returns it. The calling program must deallocate the buffer.
void file::dontGetCurrentPropertiesOnOpen | ( | ) |
Causes the open() and create() methods to call getCurrentProperties() internally so other methods of this class such as getSize() will return valid data about the file immediately. This is the default behavior.
static bool file::executable | ( | const char * | filename | ) | [static] |
Returns true if "filename" is executable by the user or false otherwise.
static bool file::exists | ( | const char * | filename | ) | [static] |
Returns true if the file exists and false otherwise.
static key_t file::generateKey | ( | const char * | filename, |
int32_t | id | ||
) | [static] |
Generates a key based on "filename" and the least signifigant 8 bits of id (which must be non-zero) suitable for use with semaphores, shared memory segments and message queues.
bool file::getAttribute | ( | const char * | name, |
uint16_t * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
unsigned long * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
int16_t * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
long * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
float * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
double * | number | ||
) | const |
Returns the value of attribute "name" in buffer "number". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
unsigned char * | character | ||
) | const |
Returns the value of attribute "name" in buffer "character". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
char * | character | ||
) | const |
Returns the value of attribute "name" in buffer "character". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
bool * | value | ||
) | const |
Returns the value of attribute "name" in buffer "value". Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
unsigned char ** | string | ||
) | const |
Returns the value of attribute "name" in buffer "string". "string" is allocated internally and must be freed by the calling program. Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
char ** | string | ||
) | const |
Returns the value of attribute "name" in buffer "string". "string" is allocated internally and must be freed by the calling program. Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
unsigned char ** | string, | ||
size_t * | size | ||
) | const |
Returns the value of attribute "name" in buffer "string" and sets "size" to the size (in bytes) of "string". "string" is allocated internally and must be freed by the calling program. Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
char ** | string, | ||
size_t * | size | ||
) | const |
Returns the value of attribute "name" in buffer "string" and sets "size" to the size (in bytes) of "string". "string" is allocated internally and must be freed by the calling program. Returns true on success and false on failure.
bool file::getAttribute | ( | const char * | name, |
void ** | buffer, | ||
size_t * | size | ||
) | const |
Returns the value of attribute "name" in buffer "buffer" and sets "size" to the size (in bytes) of "buffer". "buffer" is allocated internally and must be freed by the calling program. Returns true on success and false on failure.
blkcnt_t file::getBlockCount | ( | ) | const |
Returns the number of blocks allocated for the file or -1 for systems don't support this.
static bool file::getBlockCount | ( | const char * | filename, |
blkcnt_t * | blocks | ||
) | [static] |
Sets "blocks" to the number of blocks allocated for "filename". Returns true on success and false on failure.
blksize_t file::getBlockSize | ( | ) | const |
Returns the blocksize to use for most efficient I/O with the file or -1 for systems don't support this.
static bool file::getBlockSize | ( | const char * | filename, |
blksize_t * | size | ||
) | [static] |
Sets "size" to the blocksize to use for most efficient I/O with "filename" or -1 for systems don't support this. Returns true on success and false on failure.
static char* file::getContents | ( | const char * | name | ) | [static] |
Allocates a string large enough to accommodate the contents of the file "name" , reads the contents of the file into the string, terminates it with a NULL and returns the string. The string must be freed by the calling program.
If the file contains no data, then a string of length zero is returned. If an error occurs then a NULL is returned.
static ssize_t file::getContents | ( | const char * | name, |
unsigned char * | buffer, | ||
size_t | buffersize | ||
) | [static] |
Reads the contents of the file "name" into "buffer" of length "buffersize". If the file is larger than "buffersize" then only "buffersize" bytes of the file will be read into "buffer".
Returns the number of bytes copied into "buffer" or -1 on error.
char* file::getContents | ( | ) |
Allocates a string large enough to accommodate the contents of the currently opened file, reads the contents of the file into the string and returns the string. The string must be freed by the calling program.
If the file contains no data, then a string of length zero is returned. If an error occurs then a NULL is returned.
ssize_t file::getContents | ( | unsigned char * | buffer, |
size_t | buffersize | ||
) |
Reads the contents of the currently open file into "buffer" of length "buffersize". If the file is larger than "buffersize" then only "buffersize" bytes of the file will be read into "buffer".
Returns the number of bytes copied into "buffer" or -1 on error.
off64_t file::getCurrentPosition | ( | ) | const |
Returns the position (relative to the beginning of the file) at which the next read or write will occur, or -1 on failure.
bool file::getCurrentProperties | ( | ) |
Refreshes the current file properties as returned by getSize(), getPermissions(), etc.
Returns true on success and false on failure.
void file::getCurrentPropertiesOnOpen | ( | ) |
Causes the open() and create() methods to not to call getCurrentProperties() internally. This offers a small performance improvement which can become significant if you intend to open lots of files but don't need to know the size or any other properties about them.
If this method is called and a method such as getSize() is called afterwards, then it will call getCurrentProperties() internally.
dev_t file::getDevice | ( | ) | const |
Returns the device of the file.
static bool file::getDevice | ( | const char * | filename, |
dev_t * | dev | ||
) | [static] |
Sets "dev" to the device of "filename". Returns true on success and false on failure.
dev_t file::getDeviceType | ( | ) | const |
Returns the device type of the file.
static bool file::getDeviceType | ( | const char * | filename, |
dev_t * | devtype | ||
) | [static] |
Sets "devtype" to the device type of "filename". Returns true on success and false on failure.
ino_t file::getInode | ( | ) | const |
Returns the base inode of the file.
static bool file::getInode | ( | const char * | filename, |
ino_t * | inode | ||
) | [static] |
Sets "inode" to the base inode of the file. Returns true on success and false on failure.
void* file::getInternalFileStatisticsStructure | ( | ) |
Returns a pointer to the file stats structure used internally. (struct stat * on unix)
time_t file::getLastAccessTime | ( | ) | const |
Returns the time of last access of the file.
static bool file::getLastAccessTime | ( | const char * | filename, |
time_t * | atime | ||
) | [static] |
Sets "atime" to the last access time of "filename". Returns true on success and false on failure.
time_t file::getLastChangeTime | ( | ) | const |
Returns the time of last change of the file.
Change time IS affected by changing file permissions, ownership or creating links.
static bool file::getLastChangeTime | ( | const char * | filename, |
time_t * | ctime | ||
) | [static] |
Sets "ctime" to the last change time of "filename". Returns true on success and false on failure.
Change time IS affected by changing file permissions, ownership or creating links.
static bool file::getLastModificationTime | ( | const char * | filename, |
time_t * | mtime | ||
) | [static] |
Sets "mtime" to the last modification time of "filename". Returns true on success and false on failure.
Modification time IS NOT affected by changing file permissions, ownership or creating links.
time_t file::getLastModificationTime | ( | ) | const |
Returns the time of last modification of the file.
Modification time IS NOT affected by changing file permissions, ownership or creating links.
nlink_t file::getNumberOfHardLinks | ( | ) | const |
Returns the number of hard links to the file.
static bool file::getNumberOfHardLinks | ( | const char * | filename, |
nlink_t * | nlink | ||
) | [static] |
Sets "nlink" to the number of hard links to the file. Returns true on success and false on failure.
gid_t file::getOwnerGroupId | ( | ) | const |
Returns the group id of the file's owner.
static bool file::getOwnerGroupId | ( | const char * | filename, |
gid_t * | gid | ||
) | [static] |
Sets "gid" to the owning group of "filename". Returns true on success and false on failure.
uid_t file::getOwnerUserId | ( | ) | const |
Returns the user id of the file's owner.
static bool file::getOwnerUserId | ( | const char * | filename, |
uid_t * | uid | ||
) | [static] |
Sets "uid" to the owning user of "filename". Returns true on success and false on failure.
mode_t file::getPermissions | ( | ) | const |
Returns the permissions settings for the file.
static bool file::getPermissions | ( | const char * | filename, |
mode_t * | perms | ||
) | [static] |
Sets "perms" to the permissions of "filename". Returns true on success and false on failure.
off64_t file::getSize | ( | ) | const |
Returns the number of bytes in the file.
static bool file::getSize | ( | const char * | filename, |
off64_t * | size | ||
) | [static] |
Sets "size" to the size of "filename". Returns true on success and false on failure.
int32_t file::isBlockDevice | ( | ) | const |
Returns 1 if the file is a block device, 0 if it's not or -1 on error.
static int32_t file::isBlockDevice | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a block device, 0 if it's not or -1 on error.
static int32_t file::isCharacterDevice | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a character device, 0 if it's not or -1 on error.
int32_t file::isCharacterDevice | ( | ) | const |
Returns 1 if the file is a character device, 0 if it's not or -1 on error.
int32_t file::isDirectory | ( | ) | const |
Returns 1 if the file is a directory, 0 if it's not or -1 on error.
static int32_t file::isDirectory | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a directory, 0 if it's not or -1 on error.
int32_t file::isFifo | ( | ) | const |
Returns 1 if the file is a fifo, 0 if it's not or -1 on error.
static int32_t file::isFifo | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a fifo, 0 if it's not or -1 on error.
static int32_t file::isRegularFile | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a regular file, 0 if it's not or -1 on error.
int32_t file::isRegularFile | ( | ) | const |
Returns 1 if the file is a regular file, 0 if it's not or -1 on error.
int32_t file::isSocket | ( | ) | const |
Returns 1 if the file is a socket, 0 if it's not or -1 on error.
static int32_t file::isSocket | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a socket, 0 if it's not or -1 on error.
static int32_t file::isSymbolicLink | ( | const char * | filename | ) | [static] |
Returns 1 if "filename" is a symbolic link, 0 if it's not or -1 on error.
int32_t file::isSymbolicLink | ( | ) | const |
Returns 1 if the file is a symbolic link, 0 if it's not or -1 on error.
const char* const file::listAttributes | ( | ) | const |
Returns a NULL terminated array of the exteneded file attributes for the file or NULL if an error occurred.
Note that some filesystems do not support extended file attributes.
bool file::lockFile | ( | int16_t | type | ) | const |
Attempts to lock the entire file using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Return true on success or false otherwise.
bool file::lockFromCurrent | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the current position in the file plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockFromCurrent | ( | int16_t | type, |
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the current position in the file using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockFromEnd | ( | int16_t | type, |
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the end of the file using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockFromEnd | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the end of the file plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRegion | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at position "start" (relative to the beginning of the file) using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRemainder | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at position "start" (relative to the beginning of the file) using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRemainderFromCurrent | ( | int16_t | type | ) | const |
Attempts to lock the remainder of the file starting at the current position using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRemainderFromCurrent | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at the current position plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRemainderFromEnd | ( | int16_t | type | ) | const |
Attempts to lock the remainder of the file starting at the end using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
bool file::lockRemainderFromEnd | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at the end plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK) and blocks until the lock can be established. Returns true on success or false otherwise.
static long file::maxLinks | ( | const char * | filename | ) | [static] |
Returns the maximum number of links that can be created to "filename".
long file::maxLinks | ( | ) | const |
Returns the maximum number of links that can be created to "filename".
bool file::normalAccess | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are going to access the region of the currently open file begining at byte "start", for "len" bytes, normally so the kernel can undo any previously applied optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
bool file::onlyOnce | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are going to access the region of the currently open file begining at byte "start", for "len" bytes, only one time so the kernel can perform some optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
bool file::open | ( | const char * | name, |
int32_t | flags | ||
) |
Opens the file "name" using "flags". Returns true on success and false on failure.
bool file::open | ( | const char * | name, |
int32_t | flags, | ||
mode_t | perms | ||
) |
Opens the file "name" using "flags". If "flags" contains O_CREAT and the file doesn't already exist, it will be created with permissions "perms". Returns true on success and false on failure.
bool file::randomAccess | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are going to access the region of the currently open file begining at byte "start", for "len" bytes, randomly so the kernel can perform some optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
static bool file::readable | ( | const char * | filename | ) | [static] |
Returns true if "filename" is readable by the user or false otherwise.
static bool file::remove | ( | const char * | filename | ) | [static] |
Removes file "filename". Returns true on success and false on failure. (Will not remove a directory).
Reimplemented in shmfile.
bool file::removeAttribute | ( | const char * | name | ) | const |
Removes attribute "name". Returns true on success and false on failure.
static bool file::rename | ( | const char * | oldpath, |
const char * | newpath | ||
) | [static] |
Renames "oldpath" to "newpath". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
bool | value | ||
) | const |
Replace an existing attribute named "name" with value "value". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
uint16_t | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
int16_t | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
float | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
unsigned char | character | ||
) | const |
Replace an existing attribute named "name" with value "character". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
const char * | string | ||
) | const |
Replace an existing attribute named "name" with value "string". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
const unsigned char * | string, | ||
size_t | size | ||
) | const |
Replace an existing attribute named "name" with a value of the first "size" bytes of "string". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
const char * | string, | ||
size_t | size | ||
) | const |
Replace an existing attribute named "name" with a value of the first "size" bytes of "string". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
long | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
double | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
char | character | ||
) | const |
Replace an existing attribute named "name" with value "character". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
unsigned long | number | ||
) | const |
Replace an existing attribute named "name" with value "number". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
const unsigned char * | string | ||
) | const |
Replace an existing attribute named "name" with value "string". Returns true on success and false on failure.
bool file::replaceAttribute | ( | const char * | name, |
const void * | buffer, | ||
size_t | size | ||
) | const |
Replace an existing attribute named "name" with a value of the first "size" bytes of "buffer". Returns true on success and false on failure.
bool file::reserve | ( | off64_t | start, |
size_t | len | ||
) | const |
Reserves space on the storage medium such that a write to the region starting at "start" and continuing for "len" bytes will not fail due to lack of storage space.
Returns true if the region can be reserved and false otherwise.
static char* file::resolveSymbolicLink | ( | const char * | filename | ) | [static] |
Returns the pathname of the file that the symbolic link "filename" points to. Returns NULL on failure.
Note that this method allocates a buffer for the path internally and returns it. The calling program must deallocate this buffer.
bool file::sequentialAccess | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are going to access the region of the currently open file begining at byte "start", for "len" bytes, sequentially so the kernel can perform some optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
bool file::setAttribute | ( | const char * | name, |
const char * | string, | ||
size_t | size | ||
) | const |
Replaces existing attribute "name" with the first "size" bytes of "string" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
uint16_t | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
float | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
bool | value | ||
) | const |
Replaces existing attribute "name" with value "value" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
const char * | string | ||
) | const |
Replaces existing attribute "name" with value "string" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
const unsigned char * | string | ||
) | const |
Replaces existing attribute "name" with value "string" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
char | character | ||
) | const |
Replaces existing attribute "name" with value "character" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
const unsigned char * | string, | ||
size_t | size | ||
) | const |
Replaces existing attribute "name" with the first "size" bytes of "string" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
long | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
const void * | buffer, | ||
size_t | size | ||
) | const |
Replaces existing attribute "name" with the first "size" bytes of "buffer" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
double | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
unsigned char | character | ||
) | const |
Replaces existing attribute "name" with value "character" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
unsigned long | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
bool file::setAttribute | ( | const char * | name, |
int16_t | number | ||
) | const |
Replaces existing attribute "name" with value "number" or creates a new attribute if one doesn't already exist. Returns true on success and false on failure.
static bool file::setLastAccessAndModificationTimes | ( | const char * | filename | ) | [static] |
Overrides the last access and modification times of the file, setting them both to the current system time. Returns true on success and false on failure.
static bool file::setLastAccessAndModificationTimes | ( | const char * | filename, |
time_t | lastaccesstime, | ||
time_t | lastmodtime | ||
) | [static] |
Overrides the last access and modification times of the file, setting them to "lastaccesstime" and "lastmodtime" respectively. Returns true on success and false on failure.
static bool file::setLastAccessTime | ( | const char * | filename, |
time_t | lastaccesstime | ||
) | [static] |
Overrides the last access time of the file, setting it to "lastaccesstime". Returns true on success and false on failure.
static bool file::setLastModificationTime | ( | const char * | filename, |
time_t | lastmodtime | ||
) | [static] |
Overrides the last modification time of the file, setting it to "lastaccesstime". Returns true on success and false on failure.
off64_t file::setPositionRelativeToBeginning | ( | off64_t | offset | ) | const |
Sets the position (relative to the beginning of the file) at which the next read or write will occur to "offset". Returns that position on success or -1 on failure.
off64_t file::setPositionRelativeToCurrent | ( | off64_t | offset | ) | const |
Advances the position at which the next read or write will occur by "offset" bytes. Returns that position on success or -1 on failure.
off64_t file::setPositionRelativeToEnd | ( | off64_t | offset | ) | const |
Sets the position at which the next read or write will occur to the end of the file plus "offset" bytes. Generally, "offset" will be negative though most filesystems allow the creation of files with holes in them and that can be accomplished by using a positive "offset" and then writing data at that position. Returns the position on succes or -1 on failure.
bool file::sync | ( | ) | const |
On most filesystems, changes to files are often cached in system ram, this methods causes those changes (including changes to file metadata such as last-access and last-modifiction times) to be immediately copied to the storage medium that the file resides on.
Returns true on success and false on failure.
Note that if a hard disk has on-board write cache enabled, this method only assures that the changes has been copied into the disk's write cache, not necessarily to the disk itself.
bool file::truncate | ( | off64_t | length | ) | const |
Truncates all data beyond the first "length" bytes, resulting in a file of "length" bytes. Returns true on success and false on failure.
bool file::truncate | ( | ) | const |
Truncates all data in the file, resulting in a file of zero length. Returns true on success and false on failure.
static bool file::truncate | ( | const char * | filename, |
off64_t | length | ||
) | [static] |
Truncates the file after the first "length" bytes. Returns true on success and false on failure.
static bool file::truncate | ( | const char * | filename | ) | [static] |
Truncates the file. Returns true on success and false on failure.
bool file::tryLockFile | ( | int16_t | type | ) | const |
Attempts to lock the entire file using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockFromCurrent | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the current position in the file plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockFromCurrent | ( | int16_t | type, |
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the current position in the file using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockFromEnd | ( | int16_t | type, |
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the end of the file using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockFromEnd | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at the the end of the file plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRegion | ( | int16_t | type, |
off64_t | start, | ||
off64_t | len | ||
) | const |
Attempts to lock "len" bytes of the file starting at position "start" (relative to the beginning of the file) using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRemainder | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at position "start" (relative to the beginning of the file) using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRemainderFromCurrent | ( | int16_t | type | ) | const |
Attempts to lock the remainder of the file starting at the current position using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRemainderFromCurrent | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at the current position plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRemainderFromEnd | ( | int16_t | type | ) | const |
Attempts to lock the remainder of the file starting at the end using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::tryLockRemainderFromEnd | ( | int16_t | type, |
off64_t | start | ||
) | const |
Attempts to lock the remainder of the file starting at the end plus "start" bytes using the specified lock "type" (F_RDLCK or F_WRLCK). Returns true if the lock can be established immediately or false otherwise.
bool file::unlockFile | ( | ) | const |
Attempts to release a previosly established lock and returns true on success or false otherwise.
bool file::unlockFromCurrent | ( | off64_t | len | ) | const |
Attempts to release a previosly established lock of "len" bytes of the file starting at the current position in the file. Returns true on success or false otherwise.
bool file::unlockFromCurrent | ( | off64_t | start, |
off64_t | len | ||
) | const |
Attempts to release a previosly established lock of "len" bytes of the file starting at the current position in the file plus "start" bytes. Returns true on success or false otherwise.
bool file::unlockFromEnd | ( | off64_t | len | ) | const |
Attempts to release a previosly established lock of "len" bytes of the file starting at the end of the file. Returns true on success or false otherwise.
bool file::unlockFromEnd | ( | off64_t | start, |
off64_t | len | ||
) | const |
Attempts to release a previosly established lock of "len" bytes of the file starting at the end of the file plus "start" bytes. Returns true on success or false otherwise.
bool file::unlockRegion | ( | off64_t | start, |
off64_t | len | ||
) | const |
Attempts to release a previosly established lock of "len" bytes of the file starting at position "start" (relative to the beginning of the file). Returns true on success or false otherwise.
bool file::unlockRemainder | ( | off64_t | start | ) | const |
Attempts to release a previosly established lock on the remainder of the file, starting at position "start" (relative to the begining of the file). Returns true on success or false otherwise.
bool file::unlockRemainderFromCurrent | ( | off64_t | start | ) | const |
Attempts to release a previosly established lock on the remainder of the file, starting at the current position plus "start" bytes. Returns true on success or false otherwise.
bool file::unlockRemainderFromCurrent | ( | ) | const |
Attempts to release a previosly established lock on the remainder of the file, starting at the current position. Returns true on success or false otherwise.
bool file::unlockRemainderFromEnd | ( | off64_t | start | ) | const |
Attempts to release a previosly established lock on the remainder of the file, starting at the end plus "start" bytes. Returns true on success or false otherwise.
bool file::unlockRemainderFromEnd | ( | ) | const |
Attempts to release a previosly established lock on the remainder of the file, starting at the end. Returns true on success or false otherwise.
bool file::willNeed | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are going to access the region of the currently open file begining at byte "start", for "len" bytes, in the near future so the kernel can perform some optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
bool file::wontNeed | ( | off64_t | start, |
size_t | len | ||
) | const |
Advises the kernel that you are not going to access the region of the currently open file begining at byte "start", for "len" bytes, in the near future so the kernel can perform some optimizations.
Returns true on success and false on failure.
On operating systems don't support this method, it returns true but don't actually do anything.
static bool file::writeable | ( | const char * | filename | ) | [static] |
Returns true if "filename" is writeable by the user or false otherwise.