Vuo
1.1.0
|
A file in either a directory or an archive.
Public Member Functions | |
File (string dirPath, string filePath) | |
Creates a reference to a file that is in a directory. | |
~File (void) | |
If this file is in an archive and it was the last File object using the Archive object, closes the archive. | |
bool | isInArchive (void) |
Returns true if this file is inside an archive. | |
string | getArchivePath (void) |
Returns the path of the archive that contains this file. | |
string | getRelativePath (void) |
Returns the path of the file, relative to its enclosing directory or archive. | |
char * | getContentsAsRawData (size_t &numBytes) |
Returns the contents of the file as an array of bytes. | |
string | getContentsAsString (void) |
Returns the contents of the file as a string. | |
bool | lockForReading (bool nonBlocking=false) |
Acquires a lock on the file. | |
bool | lockForWriting (bool nonBlocking=false) |
Acquires a lock on the file. | |
void | unlock (void) |
Releases a lock on the file from lockForReading() or lockForWriting(). | |
Friends | |
class | VuoFileUtilities |
VuoFileUtilities::File::File | ( | string | dirPath, |
string | filePath | ||
) |
Creates a reference to a file that is in a directory.
VuoFileUtilities::File::~File | ( | void | ) |
If this file is in an archive and it was the last File object using the Archive object, closes the archive.
string VuoFileUtilities::File::getArchivePath | ( | void | ) |
Returns the path of the archive that contains this file.
If this file is not inside an archive, returns an empty string.
char * VuoFileUtilities::File::getContentsAsRawData | ( | size_t & | numBytes | ) |
Returns the contents of the file as an array of bytes.
[out] | numBytes | The size of the returned array. |
string VuoFileUtilities::File::getContentsAsString | ( | void | ) |
Returns the contents of the file as a string.
string VuoFileUtilities::File::getRelativePath | ( | void | ) |
Returns the path of the file, relative to its enclosing directory or archive.
bool VuoFileUtilities::File::isInArchive | ( | void | ) |
Returns true if this file is inside an archive.
bool VuoFileUtilities::File::lockForReading | ( | bool | nonBlocking = false | ) |
Acquires a lock on the file.
While this lock is held, no one else (in this or another process) can hold a lock on the file from lockForWriting(). If a lock from lockFromWriting() is already held for the file, this function downgrades the lock.
nonBlocking | True if the function should return immediately instead of waiting if the lock is not immediately available. |
bool VuoFileUtilities::File::lockForWriting | ( | bool | nonBlocking = false | ) |
Acquires a lock on the file.
While this lock is held, no one else (in this or another process) can hold a lock on the file from lockForReading() or lockForWriting(). If a lock from lockForReading() is already held for the file, this function upgrades the lock.
nonBlocking | True if the function should return immediately instead of waiting if the lock is not immediately available. |
void VuoFileUtilities::File::unlock | ( | void | ) |
Releases a lock on the file from lockForReading() or lockForWriting().
If a lock has been upgraded from reading to writing, this function fully unlocks the file (rather than downgrading the lock back to reading).