Class FileSystem
#include <FileSystem.h >
General class for file system related methods
Mostly static methods
static const char separatorChar |
File path parts separator, e.g. / |
static const string separator |
File path parts separator, e.g. / |
const string& pathName |
The path to search for the files |
const string& filenameMask |
The filemask of the files we are searching for |
vector fileList |
Vector to which to add the filenames found. This vector is not cleared in order to allow accumulation of results |
const bool stripped |
Whether we should strip off the directory name and the file extension from the results stored in the vector, e.g /a/b/foo.mask is just foo Default value: false |
Searches the the specified path for the files that satisfy the specified filemask and adds their names to the fileList vector
Return value: The number of filenames added to the fileList vector
const string& pathName |
The path to search for the files |
const string& filenameMaskRE |
The filemask regular expression of the files we are searching for |
vector fileList |
Vector to which to add the filenames found. This vector is not cleared in order to allow accumulation of results |
bool fIsExtendedExpr |
true means the regular expression is an extended regular Default value: true |
bool fIsCaseSensitive |
true means evaluation of regular expression should Default value: true |
Searches the the specified path for the files that satisfy the specified filemask regular expression and adds their names to the fileList vector
Return value: The number of filenames added to the fileList vector
const vector pathNames |
The paths to search for the files |
const string& filenameMask |
The filemask of the files we are searching for |
vector fileList |
Vector to which to add the filenames found. This vector is not cleared in order to allow accumulation of results |
Searches the the specified paths for the files that satisfy the specified filemask and adds their names to the fileList vector
Return value: The number of filenames added to the fileList vector
const vector pathNames |
The paths to search for the files expression allowing use of | char and other extensions |
const string& filenameMaskRE |
The filemask regular expression of the files we are searching for be done in a case sensitive manner |
vector fileList |
Vector to which to add the filenames found. This vector is not cleared in order to allow accumulation of results |
bool fIsExtendedExpr |
true means the regular expression is an extended regular Default value: true |
bool fIsCaseSensitive |
true means evaluation of regular expression should Default value: true |
Searches the the specified paths for the files that satisfy the specified filemask regular expression and adds their names to the fileList vector
Return value: The number of filenames added to the fileList vector
const string& fullFilename |
the fully or partially qualified filename to parse |
Get the path of a fully or partially qualified filename.
Return value: the path of the filename (with no trailling /), which may be "." if not known.
const string& fullFilename |
the fully or partially qualified filename to parse |
Get the unqualified portion, no path or drive info, of a fully or partially qualified filename
Return value: the unqualified filename.ext
const string& fullDirname |
The name of the directory you want to check. |
Test if a directory exists and is readable.
Return value: true if it exists.
const string& filename |
The name of the file. |
Check whether a file is readable
Return value: true if the file exists and is readable, false otherwise.
const string& filename |
The name of the file. |
Check to see if a file is writable
Return value: true if the file is writable, false otherwise.
const string& filename |
the name of the file to check for |
Check to see if a file exists
Return value: false if the file does not exist or if we do not have permission
const string& filename |
the name of a valid file in the file system |
Return the size of the specified file.
Return value: length (in bytes) of file; -1 on error
const string& filename |
the filename to diagnose |
Return, as a string, a bunch of diagnostic information, such as who owns a file and whatnot. For informational uses when things go wrong. Note that the string contains HTML formatting information for now; strip it out if undesired.
Return value: diagnostic info
const string& fullDirname |
the full directory name |
Make the requested directory name. If the directory already exists, return false, otherwise return true. This method is pretty stupid right now, and doesn't do much in the way of error checking.
Return value: true upon success
const string& text |
the text to search for |
const string& filename |
the file to search |
bool fCaseSensitive |
(parameter ignored) Default value: true |
bool fExtendedRegularExpr |
(parameter ignored) Default value: false |
This function 'greps' for text in a file, and returns a vector of all lines that have that text. Note:
1) It's case sensitive
2) Exact match only; regular expressions are not understood
Return value: a list of lines that match
const string& filename |
the filename to check |
string& explanation |
if not legal, an explanation of what's wrong with it |
Determine if a filename is legal. If the filename is not legal, the method will return false, and explanation will contain the reason for the failure.
Return value: true if the filename is legal.
const string& sourceFile |
filename with contents to move |
const string& destFile |
destination filename |
Move sourceFile to destFile, overwriting if necessary.
Return value: true if accomplished, false for failure.
const string& sourceFile |
filename to remove |
Remove the named file
Return value: true on success, false on failure
const string& filenameToRead |
filename to read |
vector linesRead |
|
bool fStripLeadTrailWS |
Flag: strip leading/trailing whitespace Default value: false |
unsigned int maxLinesToRead |
maximum number of lines to read Default value: 0 |
Read a file into an array of strings.
@param liensRead - (output) file content read
Return value: number of lines read
const string& filename |
filename to read |
long offset |
offset into file to begin Default value: 0 |
Read a file into a string.
Return value: file content read
FILE* f |
a pointer to an open file |
long offset |
offset into file to begin Default value: 0 |
Read a file into a string.
Return value: file content read
const string& filenameToSave |
filename to write content to |
const string& content |
the file content to save |
Save a string as the total contents of the named file
Return value: true on success, false on failure
const string& filenameToSave |
filename to write content to |
const vector <string >& content |
the file content to save |
Save a vector of strings as the total contents of the named file
Return value: true on success, false on failure
const string& filename |
input filename |
Return just the file name (no path) of the named file.
Return value: base filename without path
const string& var |
the variable name to fetched |
const string& defaultValue |
if variable undefined or blank, return this value instead |
Query an environment variable from the key file environ.conf.
Return value: value of environment variable (or defaultValue)
string cmd |
the command to execute |
Build the string to run a command through system via ksh after sourcing environ.conf.
Return value: 0 upon success, -1 on error, 1+ return code from command (see ::system())
const string& cmd |
the command to execute |
Execute a the command on the command line.
Return value: 0 upon success, -1 on error, 1+ return code from command (see ::system())
string cmd |
the command to execute |
const string& flags |
type type of pipe to open to command, e.g. r, w, or rw |
Build the string to run a command through a pipe
Return value: a FILE* to pipe; use ::pclose() to close it
const string& path |
path to search |
const string& filename_mask |
mask for filtering files |
Return NULL if no files match /filename_mask/. Return first file in directory which matches /filename_mask/. The pointer is not malloc()ed and should NOT be free()ed by you. /filename_mask/ can contain an asterisk as a wild card position, e.g. *.c, base.*, this*that, etc. The ? wildcard will match any one character, e.g. ???.c. The . character matches only the . character. activated: Otherwise, /filename_mask/ can be a regular expression (see grep(1V)).
Return value: the next filename, null string at end of list
If you are seeking multiple file names and you have already fetched the first one with find_first_file_name(), then call this routine for the next one. NULL is returned when there are no more maching names.
Return value: the next filename, null string at end of list
const string& path |
directory path to search |
const string& filename_mask |
mask for files, e.g. *.txt, sda????.dat Default value: "*" |
bool hiddenFilesOK |
true to include hidden files that start with dot, false to exclude them Default value: false |
Create a list of filenames matching the filename_mask for the particular directory path. NULL is returned if no names matched or if path is incorrect or filename_mask is NULL.
const string& filename |
Determine the size of the named file
Return value: file size upon success, -1 upon failure