PLearn 0.1
Namespaces | Functions
fileutils.h File Reference
#include <map>
#include <string>
#include <vector>
#include "PPath.h"
#include "PStream.h"
#include <nspr/prlong.h>
Include dependency graph for fileutils.h:

Go to the source code of this file.

Namespaces

namespace  PLearn
 

< for swap


Functions

int PLearn::chdir (const PPath &path)
 Change current directory.
bool PLearn::pathexists (const PPath &path)
 Returns true if the given path points to an existing regular file or directory.
bool PLearn::isdir (const PPath &path)
 Returns true if the given path is an existing directory (or a symbolic link pointing to a directory).
bool PLearn::isfile (const PPath &path)
 Returns true if the given path is an existing regular file (or a symbolic link pointing to a file).
bool PLearn::isemptyFile (const PPath &path)
 Returns true if the given path is an existing regular file (or a symbolic link pointing to a file) and the size of the file is 0.
time_t PLearn::mtime (const PPath &path)
 Returns the time of last modification of file (or 0 if file does not exist).
vector< string > PLearn::lsdir (const PPath &dirpath)
vector< PPath > PLearn::lsdir_fullpath (const PPath &dirpath)
 Same as lsdir, except the returned entries are full paths.
bool PLearn::mkdir_lowlevel (const PPath &dirname)
 Low-level cross-platform mkdir function, with the normal mkdir semantics.
bool PLearn::force_mkdir (const PPath &dirname)
void PLearn::force_mkdir_for_file (const PPath &filepath)
 Extracts the directory part of the filepath and calls force_mkdir.
bool PLearn::force_rmdir (const PPath &dirname)
PRUint64 PLearn::filesize64 (const PPath &filename)
 Returns the length of a file, measured in bytes, as a 64bit unsigned integer type defined by NSPR.
long PLearn::filesize (const PPath &filename)
 Returns the length of a file, measured in bytes, as a long.
void PLearn::cp (const PPath &srcpath, const PPath &destpath)
 Calls system with cp -R to recursively copy source to destination.
bool PLearn::rm (const PPath &file, bool fail_on_error_if_exist=false)
 Remove a file (return 'true' if removed sucessfully).
PRStatus PLearn::mv (const PPath &source, const PPath &dest, bool fail_on_error=true)
 Calls system mv command to move the given source file to destination.
PRStatus PLearn::mvforce (const PPath &source, const PPath &dest, bool fail_on_error=true)
 Same as mv, but will not prompt before overwriting.
void PLearn::touch (const PPath &file)
 Trivial unix touch.
void PLearn::readWhileMatches (PStream &in, const string &s)
 Reads while the characters read exactly match those in s.
void PLearn::skipRestOfLine (PStream &in)
 Skips everything until '
' (also consumes the '
').
void PLearn::skipBlanksAndComments (PStream &in)
 Will skip all blanks (white space, newline and #-style comments).
void PLearn::getNextNonBlankLine (PStream &in, string &line)
 Fills 'line' with the next non blank line (#-style comments are considered blank, and automatically stripped out of 'line').
int PLearn::countNonBlankLinesOfFile (const PPath &filename)
 Will return the number of non-blank lines of file.
int PLearn::peekAfterSkipBlanks (PStream &in)
 Peeks the first char after removal of blanks.
int PLearn::peekAfterSkipBlanksAndComments (PStream &in)
 Peeks the first char after removal of blanks and comments.
int PLearn::getAfterSkipBlanks (PStream &in)
 Gets the first char after removal of blanks.
int PLearn::getAfterSkipBlanksAndComments (PStream &in)
 Gets the first char after removal of blanks and comments.
PPath PLearn::newFilename (const PPath &directory="/tmp/", const string &prefix="", bool is_directory=false)
 Returns a temporary file (or directory) name suitable for a unique (one time) use.
PPath PLearn::makeFileNameValid (const PPath &filename)
 Return a valid filename from a potentially invalid one.
string PLearn::loadFileAsString (const PPath &filepath)
 Returns the whole content of the file as a string.
void PLearn::saveStringInFile (const PPath &filepath, const string &text)
 Writes the raw string into the given file.
string PLearn::readAndMacroProcess (PStream &in, map< string, string > &variables, time_t &latest, bool skip_comments=true)
 Will return the text, macro processed, with each instance of ${varname} in the text that corresponds to a key in the given map replaced by its associated value.
void PLearn::addFileAndDateVariables (const PPath &filepath, map< string, string > &variables, const time_t &latest)
string PLearn::readFileAndMacroProcess (const PPath &filepath, map< string, string > &variables, time_t &latest, bool change_dir)
string PLearn::readFileAndMacroProcess (const PPath &filepath, map< string, string > &variables, bool change_dir=false)
string PLearn::readFileAndMacroProcess (const PPath &filepath, time_t &latest)
string PLearn::readFileAndMacroProcess (const PPath &filepath)
void PLearn::addReferenceToFile (const PPath &file)
 Increase by one the number of references to a file.
void PLearn::removeReferenceToFile (const PPath &file)
 Decrease by one the number of references to a file.
unsigned int PLearn::nReferencesToFile (const PPath &file)
 Return the number of references to a file.
bool PLearn::noReferenceToFile (const PPath &file)
 Return 'true' iff there is no reference to a file.

Detailed Description

Definition in file fileutils.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines