PLearn 0.1
Namespaces | Defines | Functions | Variables
fileutils.cc File Reference
#include <unistd.h>
#include "fileutils.h"
#include "openFile.h"
#include "openString.h"
#include "PStream.h"
#include "PPath.h"
#include <plearn/base/tostring.h>
#include <plearn/base/stringutils.h>
#include <plearn/base/plerror.h>
#include <plearn/math/pl_math.h>
#include <plearn/base/PrUtils.h>
#include <nspr/prio.h>
#include <nspr/prtime.h>
#include <nspr/prerror.h>
#include <nspr/prlong.h>
#include <nspr/prenv.h>
Include dependency graph for fileutils.cc:

Go to the source code of this file.

Namespaces

namespace  PLearn
 

< for swap


Defines

#define SYSTEM_CHDIR   chdir

Functions

static PRStatus PLearn::PR_GetFileInfo64_NoWildcards (const char *fn, PRFileInfo64 *info)
 Workaround for the fact that on Windows the PR_GetFileInfo function does a wildcard expansion of the filename before returning the file stats, which slows down (for example) lookups of the modification times for a number of files by a big factor on Windows.
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.
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.
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::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.
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.
void PLearn::touch (const PPath &file)
 Trivial unix touch.
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::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::addReferenceToFile (const PPath &file)
 Increase by one the number of references to a file.
bool PLearn::noReferenceToFile (const PPath &file)
 Return 'true' iff there is no reference to a file.
unsigned int PLearn::nReferencesToFile (const PPath &file)
 Return the number of references to a file.
void PLearn::removeReferenceToFile (const PPath &file)
 Decrease by one the number of references to a file.

Variables

static map< string, unsigned intPLearn::count_refs_to_file

Define Documentation

#define SYSTEM_CHDIR   chdir

Definition at line 49 of file fileutils.cc.

Referenced by PLearn::chdir().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines