Vuo  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
VuoFileUtilities::File Class Reference

Description

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
 

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

Parameters
[out]numBytesThe size of the returned array.
Returns
The array of bytes. The caller is responsible for freeing it.
Exceptions
std::runtime_errorThe file couldn't be read.
string VuoFileUtilities::File::getContentsAsString ( void  )

Returns the contents of the file as a string.

Exceptions
std::runtime_errorThe file couldn't be read.
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.

Parameters
nonBlockingTrue if the function should return immediately instead of waiting if the lock is not immediately available.
Returns
True if the lock was acquired.
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.

Parameters
nonBlockingTrue if the function should return immediately instead of waiting if the lock is not immediately available.
Returns
True if the lock was acquired.
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).


The documentation for this class was generated from the following files: