Rudiments
Public Member Functions | Static Public Member Functions | List of all members
file Class Reference

#include <file.h>

Inherits filedescriptor.

Inherited by device, and url.

Public Member Functions

 file ()
 
virtual ~file ()
 
virtual bool open (const char *name, int32_t flags)
 
virtual bool open (const char *name, int32_t flags, mode_t perms)
 
virtual bool create (const char *name, mode_t perms)
 
virtual chargetContents ()
 
virtual ssize_t getContents (byte_t *buffer, size_t buffersize)
 
virtual ssize_t getContents (byte_t **buffer, size_t *buffersize)
 
virtual bool truncate ()
 
virtual bool truncate (off64_t size)
 
virtual bool tryLockFile (int16_t type)
 
virtual bool lockFile (int16_t type)
 
virtual bool checkLockFile (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockFile ()
 
virtual bool tryLockRegion (int16_t type, off64_t start, off64_t len)
 
virtual bool lockRegion (int16_t type, off64_t start, off64_t len)
 
virtual bool checkLockRegion (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockRegion (off64_t start, off64_t len)
 
virtual bool tryLockFromCurrent (int16_t type, off64_t len)
 
virtual bool tryLockFromCurrent (int16_t type, off64_t start, off64_t len)
 
virtual bool lockFromCurrent (int16_t type, off64_t len)
 
virtual bool lockFromCurrent (int16_t type, off64_t start, off64_t len)
 
virtual bool checkLockFromCurrent (int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool checkLockFromCurrent (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockFromCurrent (off64_t len)
 
virtual bool unlockFromCurrent (off64_t start, off64_t len)
 
virtual bool tryLockFromEnd (int16_t type, off64_t len)
 
virtual bool tryLockFromEnd (int16_t type, off64_t start, off64_t len)
 
virtual bool lockFromEnd (int16_t type, off64_t len)
 
virtual bool lockFromEnd (int16_t type, off64_t start, off64_t len)
 
virtual bool checkLockFromEnd (int16_t type, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool checkLockFromEnd (int16_t type, off64_t start, off64_t len, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockFromEnd (off64_t len)
 
virtual bool unlockFromEnd (off64_t start, off64_t len)
 
virtual bool tryLockRemainder (int16_t type, off64_t start)
 
virtual bool lockRemainder (int16_t type, off64_t start)
 
virtual bool checkLockRemainder (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockRemainder (off64_t start)
 
virtual bool tryLockRemainderFromCurrent (int16_t type)
 
virtual bool tryLockRemainderFromCurrent (int16_t type, off64_t start)
 
virtual bool lockRemainderFromCurrent (int16_t type)
 
virtual bool lockRemainderFromCurrent (int16_t type, off64_t start)
 
virtual bool checkLockRemainderFromCurrent (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool checkLockRemainderFromCurrent (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockRemainderFromCurrent ()
 
virtual bool unlockRemainderFromCurrent (off64_t start)
 
virtual bool tryLockRemainderFromEnd (int16_t type)
 
virtual bool tryLockRemainderFromEnd (int16_t type, off64_t start)
 
virtual bool lockRemainderFromEnd (int16_t type)
 
virtual bool lockRemainderFromEnd (int16_t type, off64_t start)
 
virtual bool checkLockRemainderFromEnd (int16_t type, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool checkLockRemainderFromEnd (int16_t type, off64_t start, int16_t *conftype, int16_t *confwhence, off64_t *confstart, off64_t *conflen)
 
virtual bool unlockRemainderFromEnd ()
 
virtual bool unlockRemainderFromEnd (off64_t start)
 
virtual bool adviseSequentialAccess (off64_t start, size_t len)
 
virtual bool adviseRandomAccess (off64_t start, size_t len)
 
virtual bool adviseOnlyOnce (off64_t start, size_t len)
 
virtual bool adviseWillNeed (off64_t start, size_t len)
 
virtual bool adviseWontNeed (off64_t start, size_t len)
 
virtual bool adviseNormalAccess (off64_t start, size_t len)
 
virtual bool reserve (off64_t start, size_t len)
 
virtual bool sync ()
 
virtual bool syncData ()
 
virtual void setGetCurrentPropertiesOnOpen (bool set)
 
virtual bool getCurrentProperties ()
 
virtual mode_t getPermissions ()
 
virtual uid_t getOwnerUserId ()
 
virtual gid_t getOwnerGroupId ()
 
virtual off64_t getSize ()
 
virtual blksize_t getBlockSize ()
 
virtual blkcnt_t getBlockCount ()
 
virtual int32_t isSocket ()
 
virtual int32_t isSymbolicLink ()
 
virtual int32_t isRegularFile ()
 
virtual int32_t isBlockDevice ()
 
virtual int32_t isDirectory ()
 
virtual int32_t isCharacterDevice ()
 
virtual int32_t isFifo ()
 
virtual time_t getLastAccessTime ()
 
virtual time_t getLastModificationTime ()
 
virtual time_t getLastChangeTime ()
 
virtual dev_t getDevice ()
 
virtual dev_t getDeviceType ()
 
virtual uint64_t getInode ()
 
virtual nlink_t getNumberOfHardLinks ()
 
virtual bool setPermissions (mode_t perms)
 
virtual bool changeOwner (const char *newuser, const char *newgroup)
 
virtual bool changeOwner (uid_t uid, gid_t gid)
 
virtual bool getCanChangeOwner ()
 
virtual int64_t getMaxLinks ()
 
virtual voidgetInternalFileStatisticsStructure ()
 
virtual ssize_t getContents (const char *name, byte_t **buffer, size_t *buffersize)
 
- Public Member Functions inherited from filedescriptor
 filedescriptor ()
 
virtual ~filedescriptor ()
 
virtual bool close ()
 
int32_t getFileDescriptor ()
 
void setFileDescriptor (int32_t filedesc)
 
bool setIsStream (bool isstream)
 
bool getIsStream ()
 
int32_t duplicate ()
 
bool duplicate (int32_t newfd)
 
void setSocketLayer (socketlayer *layer)
 
socketlayergetSocketLayer ()
 
virtual bool supportsBlockingAndNonBlockingModes ()
 
virtual bool setNonBlockingMode (bool usenonblockingmode)
 
virtual bool getNonBlockingMode ()
 
virtual off64_t getPosition ()
 
virtual off64_t setPositionRelativeToBeginning (off64_t offset)
 
virtual off64_t setPositionRelativeToCurrent (off64_t offset)
 
virtual off64_t setPositionRelativeToEnd (off64_t offset)
 
ssize_t write (uint16_t number)
 
ssize_t write (uint32_t number)
 
ssize_t write (uint64_t number)
 
ssize_t write (int16_t number)
 
ssize_t write (int32_t number)
 
ssize_t write (int64_t number)
 
ssize_t write (float number)
 
ssize_t write (double number)
 
ssize_t write (byte_t character)
 
ssize_t write (char character)
 
ssize_t write (wchar_t character)
 
ssize_t writeUcs2 (ucs2_t character)
 
ssize_t write (bool value)
 
ssize_t write (const byte_t *string)
 
ssize_t write (const char *string)
 
ssize_t write (const wchar_t *string)
 
ssize_t writeUcs2 (const ucs2_t *string)
 
ssize_t write (const byte_t *string, size_t size)
 
ssize_t write (const char *string, size_t length)
 
ssize_t write (const wchar_t *string, size_t length)
 
ssize_t writeUcs2 (const ucs2_t *string, size_t length)
 
ssize_t write (const void *buffer, size_t size)
 
ssize_t write (uint16_t number, int32_t sec, int32_t usec)
 
ssize_t write (uint32_t number, int32_t sec, int32_t usec)
 
ssize_t write (uint64_t number, int32_t sec, int32_t usec)
 
ssize_t write (int16_t number, int32_t sec, int32_t usec)
 
ssize_t write (int32_t number, int32_t sec, int32_t usec)
 
ssize_t write (int64_t number, int32_t sec, int32_t usec)
 
ssize_t write (float number, int32_t sec, int32_t usec)
 
ssize_t write (double number, int32_t sec, int32_t usec)
 
ssize_t write (byte_t character, int32_t sec, int32_t usec)
 
ssize_t write (char character, int32_t sec, int32_t usec)
 
ssize_t write (wchar_t character, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (ucs2_t character, int32_t sec, int32_t usec)
 
ssize_t write (bool value, int32_t sec, int32_t usec)
 
ssize_t write (const byte_t *string, int32_t sec, int32_t usec)
 
ssize_t write (const char *string, int32_t sec, int32_t usec)
 
ssize_t write (const wchar_t *string, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (const ucs2_t *string, int32_t sec, int32_t usec)
 
ssize_t write (const byte_t *string, size_t size, int32_t sec, int32_t usec)
 
ssize_t write (const char *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t write (const wchar_t *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t writeUcs2 (const ucs2_t *string, size_t length, int32_t sec, int32_t usec)
 
ssize_t write (const void *buffer, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (uint16_t *buffer)
 
ssize_t read (uint32_t *buffer)
 
ssize_t read (uint64_t *buffer)
 
ssize_t read (int16_t *buffer)
 
ssize_t read (int32_t *buffer)
 
ssize_t read (int64_t *buffer)
 
ssize_t read (float *buffer)
 
ssize_t read (double *buffer)
 
ssize_t read (byte_t *buffer)
 
ssize_t read (char *buffer)
 
ssize_t read (wchar_t *buffer)
 
ssize_t readUcs2 (ucs2_t *buffer)
 
ssize_t read (bool *buffer)
 
ssize_t read (byte_t *buffer, size_t size)
 
ssize_t read (char *buffer, size_t length)
 
ssize_t read (wchar_t *buffer, size_t length)
 
ssize_t readUcs2 (ucs2_t *buffer, size_t length)
 
ssize_t read (void *buf, size_t size)
 
ssize_t read (char **buffer, const char *terminator)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes)
 
ssize_t read (uint16_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (uint32_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (uint64_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int16_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int32_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (int64_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (float *buffer, int32_t sec, int32_t usec)
 
ssize_t read (double *buffer, int32_t sec, int32_t usec)
 
ssize_t read (byte_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (char *buffer, int32_t sec, int32_t usec)
 
ssize_t read (wchar_t *buffer, int32_t sec, int32_t usec)
 
ssize_t readUcs2 (ucs2_t *buffer, int32_t sec, int32_t usec)
 
ssize_t read (bool *buffer, int32_t sec, int32_t usec)
 
ssize_t read (byte_t *buffer, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (char *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t read (wchar_t *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t readUcs2 (ucs2_t *buffer, size_t length, int32_t sec, int32_t usec)
 
ssize_t read (void *buf, size_t size, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, char escapechar, int32_t sec, int32_t usec)
 
int32_t waitForNonBlockingRead (int32_t sec, int32_t usec)
 
int32_t waitForNonBlockingWrite (int32_t sec, int32_t usec)
 
void setRetryInterruptedReads (bool retry)
 
bool getRetryInterruptedReads ()
 
void setRetryInterruptedWrites (bool retry)
 
bool getRetryInterruptedWrites ()
 
void setRetryInterruptedWaits (bool retry)
 
bool getRetryInterruptedWaits ()
 
void setRetryInterruptedFcntl (bool retry)
 
bool getRetryInterruptedFcntl ()
 
void setRetryInterruptedIoctl (bool retry)
 
bool getRetryInterruptedIoctl ()
 
void setAllowShortReads (bool allow)
 
bool getAllowShortReads ()
 
void setAllowShortWrites (bool allow)
 
bool getAllowShortWrites ()
 
virtual bool passFileDescriptor (int32_t fd)
 
virtual bool passFileDescriptor (int32_t fd, int32_t sec, int32_t usec)
 
virtual bool receiveFileDescriptor (int32_t *fd)
 
virtual bool receiveFileDescriptor (int32_t *fd, int32_t sec, int32_t usec)
 
virtual bool passSocket (int32_t sock)
 
virtual bool passSocket (int32_t sock, int32_t sec, int32_t usec)
 
virtual bool receiveSocket (int32_t *sock)
 
virtual bool receiveSocket (int32_t *sock, int32_t sec, int32_t usec)
 
void setTranslateByteOrder (bool translate)
 
bool getTranslateByteOrder ()
 
virtual int32_t fCntl (int32_t command, long arg)
 
virtual int32_t ioCtl (int32_t command, void *arg)
 
bool setNaglesAlgorithmEnabled (bool enabled)
 
bool getNaglesAlgorithmEnabled ()
 
bool setSocketWriteBufferSize (int32_t size)
 
bool getSocketWriteBufferSize (int32_t *size)
 
bool setSocketReadBufferSize (int32_t size)
 
bool getSocketReadBufferSize (int32_t *size)
 
bool disableIPv4 ()
 
bool enableIPv4 ()
 
const chargetType ()
 
chargetPeerAddress ()
 
bool setWriteBufferSize (size_t size)
 
size_t getWriteBufferSize ()
 
bool flushWriteBuffer (int32_t sec, int32_t usec)
 
bool setReadBufferSize (size_t size)
 
size_t getReadBufferSize ()
 
void setMmapBufferingEnabled (bool enabled)
 
bool getMmapBufferingEnabled ()
 
bool isCurrentBlockMmapBuffered ()
 
off64_t getCurrentBlockOffset ()
 
bool setCloseOnExec (bool close)
 
bool getCloseOnExec ()
 
- Public Member Functions inherited from input
 input ()
 
virtual ~input ()
 
ssize_t read (char **buffer, const char *terminator)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes)
 
ssize_t read (char **buffer, const char *terminator, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, int32_t sec, int32_t usec)
 
ssize_t read (char **buffer, const char *terminator, size_t maxbytes, char escapechar, int32_t sec, int32_t usec)
 
- Public Member Functions inherited from object
virtual ~object ()
 
- Public Member Functions inherited from output
 output ()
 
virtual ~output ()
 
virtual ssize_t printf (const char *format,...)
 
virtual ssize_t printf (const char *format, va_list *argp)
 
virtual ssize_t printf (const wchar_t *format,...)
 
virtual ssize_t printf (const wchar_t *format, va_list *argp)
 
virtual ssize_t printfUcs2 (const ucs2_t *format,...)
 
virtual ssize_t printfUcs2 (const ucs2_t *format, va_list *argp)
 
void safePrint (byte_t c)
 
void safePrint (const byte_t *str)
 
void safePrint (const byte_t *str, int32_t length)
 
void safePrint (char c)
 
void safePrint (const char *str)
 
void safePrint (const char *str, int32_t length)
 
void printBits (byte_t value)
 
void printBits (uint16_t value)
 
void printBits (uint32_t value)
 
void printBits (uint64_t value)
 
void printBits (char value)
 
void printBits (int16_t value)
 
void printBits (int32_t value)
 
void printBits (int64_t value)
 
void printBits (const byte_t *bits, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size, uint16_t indent)
 

Static Public Member Functions

static bool createFile (const char *name, mode_t perms)
 
static bool createFifo (const char *filename, mode_t perms)
 
static int32_t createTemporaryFile (char *templatefilename)
 
static int32_t createTemporaryFile (char *templatefilename, mode_t perms)
 
static bool createHardLink (const char *oldpath, const char *newpath)
 
static bool createSymbolicLink (const char *oldpath, const char *newpath)
 
static charresolveSymbolicLink (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 size)
 
static chargetContents (const char *name)
 
static ssize_t getContents (const char *name, byte_t *buffer, size_t buffersize)
 
static bool exists (const char *filename)
 
static bool isReadable (const char *filename)
 
static bool isWriteable (const char *filename)
 
static bool isExecutable (const char *filename)
 
static bool isAccessible (const char *filename, int32_t mode)
 
static bool getLastChangeTime (const char *filename, time_t *ctime)
 
static bool setPermissions (const char *filename, mode_t perms)
 
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 getCanChangeOwner (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 chargetDirName (const char *filename)
 
static chargetBaseName (const char *filename)
 
static chargetBaseName (const char *filename, const char *ext)
 
static chargetExtension (const char *filename)
 
static chargetEightDotThree (const char *filename)
 
static key_t generateKey (const char *filename, int32_t id)
 
static int64_t getMaxLinks (const char *filename)
 
static bool getMatchingFileNames (const char *pattern, linkedlist< char * > *matches)
 
static bool getMatchingFileNames (const char *const *patterns, linkedlist< char * > *matches)
 
static bool getMatchingFileNames (linkedlist< const char * > *patterns, linkedlist< char * > *matches)
 
static bool getMatchingFileNames (linkedlist< char * > *patterns, linkedlist< char * > *matches)
 
- Static Public Member Functions inherited from filedescriptor
static bool supportsPassAndReceiveFileDescriptor ()
 
static bool supportsPassAndReceiveSocket ()
 
static bool createPipe (filedescriptor *readfd, filedescriptor *writefd)
 
static uint16_t convertHostToNet (uint16_t value)
 
static uint32_t convertHostToNet (uint32_t value)
 
static uint64_t convertHostToNet (uint64_t value)
 
static uint16_t convertNetToHost (uint16_t value)
 
static uint32_t convertNetToHost (uint32_t value)
 
static uint64_t convertNetToHost (uint64_t value)
 
static uint16_t convertHostToLittleEndian (uint16_t value)
 
static uint32_t convertHostToLittleEndian (uint32_t value)
 
static uint64_t convertHostToLittleEndian (uint64_t value)
 
static uint16_t convertLittleEndianToHost (uint16_t value)
 
static uint32_t convertLittleEndianToHost (uint32_t value)
 
static uint64_t convertLittleEndianToHost (uint64_t value)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ file()

file::file ( )

Creates an instance of the file class.

◆ ~file()

virtual file::~file ( )
virtual

Deletes this instance of the file class.

Member Function Documentation

◆ adviseNormalAccess()

virtual bool file::adviseNormalAccess ( off64_t start,
size_t len )
virtual

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.

◆ adviseOnlyOnce()

virtual bool file::adviseOnlyOnce ( off64_t start,
size_t len )
virtual

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.

◆ adviseRandomAccess()

virtual bool file::adviseRandomAccess ( off64_t start,
size_t len )
virtual

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.

◆ adviseSequentialAccess()

virtual bool file::adviseSequentialAccess ( off64_t start,
size_t len )
virtual

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.

◆ adviseWillNeed()

virtual bool file::adviseWillNeed ( off64_t start,
size_t len )
virtual

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.

◆ adviseWontNeed()

virtual bool file::adviseWontNeed ( off64_t start,
size_t len )
virtual

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.

◆ changeOwner() [1/4]

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.

◆ changeOwner() [2/4]

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.

◆ changeOwner() [3/4]

virtual bool file::changeOwner ( const char * newuser,
const char * newgroup )
virtual

Changes the user and/or group that owns the file. Returns true on success and false on failure.

◆ changeOwner() [4/4]

virtual bool file::changeOwner ( uid_t uid,
gid_t gid )
virtual

Changes the user that owns the file. Returns true on success and false on failure.

◆ checkLockFile()

virtual bool file::checkLockFile ( int16_t type,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockFromCurrent() [1/2]

virtual bool file::checkLockFromCurrent ( int16_t type,
off64_t len,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockFromCurrent() [2/2]

virtual bool file::checkLockFromCurrent ( int16_t type,
off64_t start,
off64_t len,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockFromEnd() [1/2]

virtual bool file::checkLockFromEnd ( int16_t type,
off64_t len,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockFromEnd() [2/2]

virtual bool file::checkLockFromEnd ( int16_t type,
off64_t start,
off64_t len,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRegion()

virtual bool file::checkLockRegion ( int16_t type,
off64_t start,
off64_t len,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRemainder()

virtual bool file::checkLockRemainder ( int16_t type,
off64_t start,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRemainderFromCurrent() [1/2]

virtual bool file::checkLockRemainderFromCurrent ( int16_t type,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRemainderFromCurrent() [2/2]

virtual bool file::checkLockRemainderFromCurrent ( int16_t type,
off64_t start,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRemainderFromEnd() [1/2]

virtual bool file::checkLockRemainderFromEnd ( int16_t type,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ checkLockRemainderFromEnd() [2/2]

virtual bool file::checkLockRemainderFromEnd ( int16_t type,
off64_t start,
int16_t * conftype,
int16_t * confwhence,
off64_t * confstart,
off64_t * conflen )
virtual

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.

◆ create()

virtual bool file::create ( const char * name,
mode_t perms )
virtual

Creates the file "name" with permissions "perms". If the file already exists, it will be truncated. Returns true on success and false on failure.

Note that if "perms" is 0 then the method will fail.

Equivalent to calling: open(name,O_CREAT|O_WRONLY|O_TRUNC|O_BINARY,perms)

◆ createFifo()

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.

◆ createFile()

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.

◆ createHardLink()

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.

◆ createSymbolicLink()

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.

◆ createTemporaryFile() [1/2]

static int32_t file::createTemporaryFile ( char * templatefilename)
static

Creates a (presumably) 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.

◆ createTemporaryFile() [2/2]

static int32_t file::createTemporaryFile ( char * templatefilename,
mode_t perms )
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.

Sets the permissions of the file to "perms". If permissions cannot be set then the file is removed and the call fails.

Opens and returns the file descriptor handle of the file on success and -1 on failure.

◆ exists()

static bool file::exists ( const char * filename)
static

Returns true if the file exists and false otherwise.

◆ generateKey()

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.

◆ getBaseName() [1/2]

static char * file::getBaseName ( 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.

◆ getBaseName() [2/2]

static char * file::getBaseName ( const char * filename,
const char * ext )
static

Returns the non-directory portion of "filename", truncating "ext". This method allocates a buffer internally and returns it. The calling program must deallocate the buffer.

◆ getBlockCount()

virtual blkcnt_t file::getBlockCount ( )
virtual

Returns the number of blocks allocated for the file or -1 for systems don't support this.

◆ getBlockSize()

virtual blksize_t file::getBlockSize ( )
virtual

Returns the blocksize to use for most efficient I/O with the file or -1 for systems don't support this.

◆ getCanChangeOwner() [1/2]

virtual bool file::getCanChangeOwner ( )
virtual

Returns true if any of the changeOwner() methods are allowed on "filename" and false otherwise.

◆ getCanChangeOwner() [2/2]

static bool file::getCanChangeOwner ( const char * filename)
static

Returns true if any of the changeOwner methods are allowed on "filename" and false otherwise.

◆ getContents() [1/6]

virtual char * file::getContents ( )
virtual

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.

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

If the file contains no data, then an empty string is returned. If an error occurs then a NULL is returned.

◆ getContents() [2/6]

virtual ssize_t file::getContents ( byte_t ** buffer,
size_t * buffersize )
virtual

Allocates "buffer" large enough to accommodate the contents of the currently opened file, reads the contents of the file into "buffer" and sets "buffersize" to the size of the buffer. "buffer" must be freed by the calling program.

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

Returns the number of bytes copied into "buffer" or -1 on error.

◆ getContents() [3/6]

virtual ssize_t file::getContents ( byte_t * buffer,
size_t buffersize )
virtual

Reads the contents of the currently open file into "buffer" of size "buffersize". If the file is larger than "buffersize" then only "buffersize" bytes of the file will be read into "buffer".

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

Returns the number of bytes copied into "buffer" or -1 on error.

◆ getContents() [4/6]

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.

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

If the file contains no data, then an empty string is returned. If an error occurs then a NULL is returned.

◆ getContents() [5/6]

virtual ssize_t file::getContents ( const char * name,
byte_t ** buffer,
size_t * buffersize )
virtual

Allocates "buffer" large enough to accommodate the contents of the file "name", reads the contents of the file into "buffer" and sets "buffersize" to the size of the buffer. "buffer" must be freed by the calling program.

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

Returns the number of bytes copied into "buffer" or -1 on error.

◆ getContents() [6/6]

static ssize_t file::getContents ( const char * name,
byte_t * buffer,
size_t buffersize )
static

Reads the contents of the file "name" into "buffer" of size "buffersize". If the file is larger than "buffersize" then only "buffersize" bytes of the file will be read into "buffer".

Note: The contents returned by this method are as-is. No end-of-line translation is performed.

Returns the number of bytes copied into "buffer" or -1 on error.

◆ getCurrentProperties()

virtual bool file::getCurrentProperties ( )
virtual

Refreshes the current file properties as returned by getSize(), getPermissions(), etc.

Returns true on success and false on failure.

◆ getDevice()

virtual dev_t file::getDevice ( )
virtual

Returns the device of the file.

◆ getDeviceType()

virtual dev_t file::getDeviceType ( )
virtual

Returns the device type of the file.

◆ getDirName()

static char * file::getDirName ( 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.

◆ getEightDotThree()

static char * file::getEightDotThree ( const char * filename)
static

Translates the basename of "filename" to an 8.3 format, performing substitutions in the same way that Windows does. This method allocates a buffer internally and returns it. The calling program must deallocate the buffer.

◆ getExtension()

static char * file::getExtension ( const char * filename)
static

Returns the portion of "filename" after the last dot, including the dot, or an empty string if the filename contains no dot. The output should be suitable to be passed in as the "ext" parameter when calling basename().

◆ getInode()

virtual uint64_t file::getInode ( )
virtual

Returns the base inode of the file.

◆ getInternalFileStatisticsStructure()

virtual void * file::getInternalFileStatisticsStructure ( )
virtual

Returns a pointer to the file stats structure used internally. (struct stat * on unix)

◆ getLastAccessTime()

virtual time_t file::getLastAccessTime ( )
virtual

Returns the time of last access of the file.

◆ getLastChangeTime() [1/2]

virtual time_t file::getLastChangeTime ( )
virtual

Returns the time of last change of the file.

Change time IS affected by changing file permissions, ownership or creating links.

◆ getLastChangeTime() [2/2]

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.

◆ getLastModificationTime()

virtual time_t file::getLastModificationTime ( )
virtual

Returns the time of last modification of the file.

Modification time IS NOT affected by changing file permissions, ownership or creating links.

◆ getMatchingFileNames() [1/4]

static bool file::getMatchingFileNames ( const char *const * patterns,
linkedlist< char * > * matches )
static

Populates "matches" with the set of files whos names match any of the patterns provided in the NULL-terminated array "pattern".

Storage for the strings appended to "matches" is allocated internally and must be deleted by the calling program.

Returns true on success or false on failure.

Note that on failure, "matches" may be partially populated.

◆ getMatchingFileNames() [2/4]

static bool file::getMatchingFileNames ( const char * pattern,
linkedlist< char * > * matches )
static

Populates "matches" with the set of files whos names match "pattern".

Storage for the strings appended to "matches" is allocated internally and must be deleted by the calling program.

Returns true on success or false on failure.

Note that on failure, "matches" may be partially populated.

◆ getMatchingFileNames() [3/4]

static bool file::getMatchingFileNames ( linkedlist< char * > * patterns,
linkedlist< char * > * matches )
static

Populates "matches" with the set of files whos names match any of the patterns provided in the linked list "pattern".

Storage for the strings appended to "matches" is allocated internally and must be deleted by the calling program.

Returns true on success or false on failure.

Note that on failure, "matches" may be partially populated.

◆ getMatchingFileNames() [4/4]

static bool file::getMatchingFileNames ( linkedlist< const char * > * patterns,
linkedlist< char * > * matches )
static

Populates "matches" with the set of files whos names match any of the patterns provided in the linked list "pattern".

Storage for the strings appended to "matches" is allocated internally and must be deleted by the calling program.

Returns true on success or false on failure.

Note that on failure, "matches" may be partially populated.

◆ getMaxLinks() [1/2]

virtual int64_t file::getMaxLinks ( )
virtual

Returns the maximum number of links that can be created to "filename".

◆ getMaxLinks() [2/2]

static int64_t file::getMaxLinks ( const char * filename)
static

Returns the maximum number of links that can be created to "filename".

◆ getNumberOfHardLinks()

virtual nlink_t file::getNumberOfHardLinks ( )
virtual

Returns the number of hard links to the file.

◆ getOwnerGroupId()

virtual gid_t file::getOwnerGroupId ( )
virtual

Returns the group id of the file's owner.

◆ getOwnerUserId()

virtual uid_t file::getOwnerUserId ( )
virtual

Returns the user id of the file's owner.

◆ getPermissions()

virtual mode_t file::getPermissions ( )
virtual

Returns the permissions settings for the file.

◆ getSize()

virtual off64_t file::getSize ( )
virtual

Returns the number of bytes in the file.

◆ isAccessible()

static bool file::isAccessible ( 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.

◆ isBlockDevice()

virtual int32_t file::isBlockDevice ( )
virtual

Returns 1 if the file is a block device, 0 if it's not or -1 on error.

◆ isCharacterDevice()

virtual int32_t file::isCharacterDevice ( )
virtual

Returns 1 if the file is a character device, 0 if it's not or -1 on error.

◆ isDirectory()

virtual int32_t file::isDirectory ( )
virtual

Returns 1 if the file is a directory, 0 if it's not or -1 on error.

◆ isExecutable()

static bool file::isExecutable ( const char * filename)
static

Returns true if "filename" is executable by the user or false otherwise.

◆ isFifo()

virtual int32_t file::isFifo ( )
virtual

Returns 1 if the file is a fifo, 0 if it's not or -1 on error.

◆ isReadable()

static bool file::isReadable ( const char * filename)
static

Returns true if "filename" is readable by the user or false otherwise.

◆ isRegularFile()

virtual int32_t file::isRegularFile ( )
virtual

Returns 1 if the file is a regular file, 0 if it's not or -1 on error.

◆ isSocket()

virtual int32_t file::isSocket ( )
virtual

Returns 1 if the file is a socket, 0 if it's not or -1 on error.

◆ isSymbolicLink()

virtual int32_t file::isSymbolicLink ( )
virtual

Returns 1 if the file is a symbolic link, 0 if it's not or -1 on error.

◆ isWriteable()

static bool file::isWriteable ( const char * filename)
static

Returns true if "filename" is writeable by the user or false otherwise.

◆ lockFile()

virtual bool file::lockFile ( int16_t type)
virtual

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.

◆ lockFromCurrent() [1/2]

virtual bool file::lockFromCurrent ( int16_t type,
off64_t len )
virtual

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.

◆ lockFromCurrent() [2/2]

virtual bool file::lockFromCurrent ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ lockFromEnd() [1/2]

virtual bool file::lockFromEnd ( int16_t type,
off64_t len )
virtual

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.

◆ lockFromEnd() [2/2]

virtual bool file::lockFromEnd ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ lockRegion()

virtual bool file::lockRegion ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ lockRemainder()

virtual bool file::lockRemainder ( int16_t type,
off64_t start )
virtual

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.

◆ lockRemainderFromCurrent() [1/2]

virtual bool file::lockRemainderFromCurrent ( int16_t type)
virtual

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.

◆ lockRemainderFromCurrent() [2/2]

virtual bool file::lockRemainderFromCurrent ( int16_t type,
off64_t start )
virtual

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.

◆ lockRemainderFromEnd() [1/2]

virtual bool file::lockRemainderFromEnd ( int16_t type)
virtual

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.

◆ lockRemainderFromEnd() [2/2]

virtual bool file::lockRemainderFromEnd ( int16_t type,
off64_t start )
virtual

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.

◆ open() [1/2]

virtual bool file::open ( const char * name,
int32_t flags )
virtual

Opens the file "name" using "flags".

"flags" may contain one more more of the following flags, or'ed together:

O_RDONLY - Open the file in read-only mode.

O_WRONLY - Open the file in write-only mode.

O_RDWR - Open the file in write-only mode.

O_APPEND - All writes will occur at end of the file. (NOTE: This flag conflicts with buffering. Don't use when also using buffering.)

O_TRUNC - Truncate the file. Requires O_WRONLY or O_RDWR.

Many platforms support additional, platform-specific flags.

Note that since this method doesn't allow file permissions to be set, attempts to open the file with the O_CREAT flag (which creates the file if it doesn't exist) will fail.

Returns true on success and false on failure.

◆ open() [2/2]

virtual bool file::open ( const char * name,
int32_t flags,
mode_t perms )
virtual

Opens the file "name" using "flags".

"flags" may contain one more more of the following flags, or'ed together:

O_RDONLY - Open the file in read-only mode.

O_WRONLY - Open the file in write-only mode.

O_RDWR - Open the file in write-only mode.

O_APPEND - All writes will occur at end of the file. (NOTE: This flag conflicts with buffering. Don't use when also using buffering.)

O_TRUNC - Truncate the file. Requires O_WRONLY or O_RDWR.

O_CREAT - Creates the file if it doesn't exist. See O_EXCL.

O_EXCL - Requires O_CREAT. Causes O_CREAT to fail if the file already exists. Without O_EXCL, O_CREAT will succeed, and just open the file, if the file already exists.

Many platforms support additional, platform-specific flags.

If "flags" contains O_CREAT and the file doesn't already exist, then it will be created with permissions "perms". Note that if "perms" is 0 then the method will fail.

Returns true on success and false on failure.

◆ remove()

static bool file::remove ( const char * filename)
static

Removes file "filename". Returns true on success and false on failure. (Will not remove a directory).

◆ rename()

static bool file::rename ( const char * oldpath,
const char * newpath )
static

Renames "oldpath" to "newpath". Returns true on success and false on failure.

◆ reserve()

virtual bool file::reserve ( off64_t start,
size_t len )
virtual

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.

◆ resolveSymbolicLink()

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.

◆ setGetCurrentPropertiesOnOpen()

virtual void file::setGetCurrentPropertiesOnOpen ( bool set)
virtual

If "getcurrentpropertiesonopen" is true, then open() and create() methods will call getCurrentProperties() internally so other methods of this class such as getSize() will return valid data about the file immediately.

If "getcurrentpropertiesonopen" is false, then open() and create() methods will not 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 with false and a method such as getSize() is called afterwards, then it will call getCurrentProperties() internally.

Defaults to true.

◆ setLastAccessAndModificationTimes() [1/2]

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.

◆ setLastAccessAndModificationTimes() [2/2]

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.

◆ setLastAccessTime()

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.

◆ setLastModificationTime()

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.

◆ setPermissions() [1/2]

static bool file::setPermissions ( const char * filename,
mode_t perms )
static

Sets the permissions of the file to "perms". Returns true on success and false on failure.

◆ setPermissions() [2/2]

virtual bool file::setPermissions ( mode_t perms)
virtual

Sets the permissions of the file to "perms". Returns true on success and false on failure.

◆ sync()

virtual bool file::sync ( )
virtual

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.

◆ syncData()

virtual bool file::syncData ( )
virtual

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.

◆ truncate() [1/4]

virtual bool file::truncate ( )
virtual

Truncates all data in the file, resulting in a file of zero bytes. Returns true on success and false on failure.

◆ truncate() [2/4]

static bool file::truncate ( const char * filename)
static

Truncates the file. Returns true on success and false on failure.

◆ truncate() [3/4]

static bool file::truncate ( const char * filename,
off64_t size )
static

Truncates the file after the first "size" bytes. Returns true on success and false on failure.

◆ truncate() [4/4]

virtual bool file::truncate ( off64_t size)
virtual

Truncates all data beyond the first "size" bytes, resulting in a file of "size" bytes. Returns true on success and false on failure.

◆ tryLockFile()

virtual bool file::tryLockFile ( int16_t type)
virtual

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.

◆ tryLockFromCurrent() [1/2]

virtual bool file::tryLockFromCurrent ( int16_t type,
off64_t len )
virtual

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.

◆ tryLockFromCurrent() [2/2]

virtual bool file::tryLockFromCurrent ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ tryLockFromEnd() [1/2]

virtual bool file::tryLockFromEnd ( int16_t type,
off64_t len )
virtual

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.

◆ tryLockFromEnd() [2/2]

virtual bool file::tryLockFromEnd ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ tryLockRegion()

virtual bool file::tryLockRegion ( int16_t type,
off64_t start,
off64_t len )
virtual

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.

◆ tryLockRemainder()

virtual bool file::tryLockRemainder ( int16_t type,
off64_t start )
virtual

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.

◆ tryLockRemainderFromCurrent() [1/2]

virtual bool file::tryLockRemainderFromCurrent ( int16_t type)
virtual

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.

◆ tryLockRemainderFromCurrent() [2/2]

virtual bool file::tryLockRemainderFromCurrent ( int16_t type,
off64_t start )
virtual

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.

◆ tryLockRemainderFromEnd() [1/2]

virtual bool file::tryLockRemainderFromEnd ( int16_t type)
virtual

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.

◆ tryLockRemainderFromEnd() [2/2]

virtual bool file::tryLockRemainderFromEnd ( int16_t type,
off64_t start )
virtual

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.

◆ unlockFile()

virtual bool file::unlockFile ( )
virtual

Attempts to release a previosly established lock and returns true on success or false otherwise.

◆ unlockFromCurrent() [1/2]

virtual bool file::unlockFromCurrent ( off64_t len)
virtual

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.

◆ unlockFromCurrent() [2/2]

virtual bool file::unlockFromCurrent ( off64_t start,
off64_t len )
virtual

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.

◆ unlockFromEnd() [1/2]

virtual bool file::unlockFromEnd ( off64_t len)
virtual

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.

◆ unlockFromEnd() [2/2]

virtual bool file::unlockFromEnd ( off64_t start,
off64_t len )
virtual

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.

◆ unlockRegion()

virtual bool file::unlockRegion ( off64_t start,
off64_t len )
virtual

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.

◆ unlockRemainder()

virtual bool file::unlockRemainder ( off64_t start)
virtual

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.

◆ unlockRemainderFromCurrent() [1/2]

virtual bool file::unlockRemainderFromCurrent ( )
virtual

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.

◆ unlockRemainderFromCurrent() [2/2]

virtual bool file::unlockRemainderFromCurrent ( off64_t start)
virtual

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.

◆ unlockRemainderFromEnd() [1/2]

virtual bool file::unlockRemainderFromEnd ( )
virtual

Attempts to release a previosly established lock on the remainder of the file, starting at the end. Returns true on success or false otherwise.

◆ unlockRemainderFromEnd() [2/2]

virtual bool file::unlockRemainderFromEnd ( off64_t start)
virtual

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.