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

Description

Functions for dealing with files.

Classes

class  File
 A file in either a directory or an archive. More...
 

Static Public Member Functions

static void splitPath (string path, string &dir, string &file, string &extension)
 Splits path into its directory, file name, and file extension.
 
static string makeTmpFile (string file, string extension, string directory="/tmp")
 Creates a new temporary file, avoiding any name conflicts with existing files.
 
static string makeTmpDir (string dir)
 Creates a new temporary directory, avoiding any name conflicts with existing files.
 
static FILE * stringToCFile (const char *string)
 Writes the contents of the input string to a C file.
 
static string cFileToString (FILE *file)
 Reads from the file handle into a string.
 
static bool fileExists (string path)
 Returns true if the file exists.
 
static set< File * > findAllFilesInDirectory (string dirPath, set< string > archiveExtensions=set< string >())
 Searches a directory for files.
 
static set< File * > findFilesInDirectory (string dirPath, set< string > extensions, set< string > archiveExtensions=set< string >())
 Searches a directory for files with a given extension.
 
static set< File * > findAllFilesInArchive (string archivePath)
 Recursively searches an archive for files.
 
static set< File * > findFilesInArchive (string archivePath, string dirPath, set< string > extensions)
 Recursively searches an archive for files within a given directory and with a given extension.
 
static string getArchiveFileContentsAsString (string archivePath, string filePath)
 Returns the contents of a file within an archive.
 

Member Function Documentation

string VuoFileUtilities::cFileToString ( FILE *  file)
static

Reads from the file handle into a string.

Parameters
fileAn open file handle. It may be a regular file or a pipe.
Returns
The characters read from the file handle until the end of file was reached.
bool VuoFileUtilities::fileExists ( string  path)
static

Returns true if the file exists.

set< VuoFileUtilities::File * > VuoFileUtilities::findAllFilesInArchive ( string  archivePath)
static

Recursively searches an archive for files.

Parameters
archivePathThe archive to search in.
Returns
All files found.
set< VuoFileUtilities::File * > VuoFileUtilities::findAllFilesInDirectory ( string  dirPath,
set< string >  archiveExtensions = set<string>() 
)
static

Searches a directory for files.

Parameters
dirPathThe directory to search in. Only the top level is searched.
archiveExtensionsThe file extensions for archives to search in. Any archive with one of these extensions found in the top level of the directory will be searched recursively.
Returns
All files found.
Todo:
Search recursively - https://b33p.net/kosada/node/2468
set< VuoFileUtilities::File * > VuoFileUtilities::findFilesInArchive ( string  archivePath,
string  dirPath,
set< string >  extensions 
)
static

Recursively searches an archive for files within a given directory and with a given extension.

Parameters
archivePathThe archive to search in.
dirPathThe directory to search in within the archive. The path should be relative to the archive's root. The path should omit the trailing file separator (e.g. "examples" not "examples/").
extensionsThe file extensions to search for, without the '.' character (e.g. "bc" not ".bc").
Returns
All files found.
set< VuoFileUtilities::File * > VuoFileUtilities::findFilesInDirectory ( string  dirPath,
set< string >  extensions,
set< string >  archiveExtensions = set<string>() 
)
static

Searches a directory for files with a given extension.

Parameters
dirPathThe directory to search in. Only the top level is searched.
archiveExtensionsThe file extensions for archives to search in. Any archive with one of these extensions found in the top level of the directory will be searched recursively.
extensionsThe file extensions to search for, without the '.' character (e.g. "bc" not ".bc").
Returns
All files found.
string VuoFileUtilities::getArchiveFileContentsAsString ( string  archivePath,
string  filePath 
)
static

Returns the contents of a file within an archive.

If the file doesn't exist, returns an empty string.

Parameters
archivePathThe archive containing the file.
filePathThe file. The path should be relative to the archive's root.
Returns
The file's contents.
string VuoFileUtilities::makeTmpDir ( string  dir)
static

Creates a new temporary directory, avoiding any name conflicts with existing files.

Returns the path of the directory.

string VuoFileUtilities::makeTmpFile ( string  file,
string  extension,
string  directory = "/tmp" 
)
static

Creates a new temporary file, avoiding any name conflicts with existing files.

Creates the file in the specified directory if one is provided, or in "/tmp" otherwise.

Returns the path of the file.

Todo:
Keep file open and return file handle. (https://b33p.net/kosada/node/4987)
void VuoFileUtilities::splitPath ( string  path,
string &  dir,
string &  file,
string &  extension 
)
static

Splits path into its directory, file name, and file extension.

Parameters
[in]pathThe path to split.
[out]dirThe directory in path, if any. Ends with a file separator (e.g. '/') if there was one in path.
[out]fileThe file name in path, if any.
[out]extensionThe file extension in path, if any. Does not include the '.' character.
FILE * VuoFileUtilities::stringToCFile ( const char *  string)
static

Writes the contents of the input string to a C file.


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