HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_FileUtil Class Reference

#include <UT_FileUtil.h>

Public Types

enum  UT_RemoveDepth { IF_EMPTY, ALL_CONTENTS }
 

Public Member Functions

 UT_FileUtil ()
 
virtual ~UT_FileUtil ()
 
int removeOverrideFiles (const char *newbasepath, const char *relpath, const char *fname, const char *english, int flags, const char *stripinfo=0)
 
virtual void showError (const char *error, int severity=2)
 
virtual int showPrompt (const char *prompt)
 

Static Public Member Functions

static int64 getFileSize (const char *path)
 
static exint getFileModTime (const char *path)
 
static exint getRecursiveDirMaxModTime (const char *path)
 
static int getMaxFileDescriptors ()
 
static int resolveSymbolicLinks (const char *path, UT_WorkBuffer &contents, bool allow_dangling_link=false)
 
static int copyFile (const char *srcname, const char *dstname)
 
static int copyDir (const char *srcname, const char *dstname)
 
static int copyFileToStream (const char *srcname, std::ostream &os)
 
static int moveFile (const char *srcname, const char *dstname)
 
static int removeFile (const char *fname)
 
static int removeDir (const char *dname, UT_RemoveDepth depth=IF_EMPTY)
 
static bool makeDir (const char *path, mode_t mode=0777, bool ignore_umask=false)
 
static bool makeDirs (const char *path, mode_t mode=0777, bool ignore_umask=false)
 
static bool lockFile (int fd)
 
static bool unlockFile (int fd)
 
static bool writeLockFile (int fd)
 
static bool readLockFile (int fd)
 
static void upDirectory (char *path, int levels)
 
static int removeLinesFromFile (const char *fname, const char *prefix, int readonly=0)
 
static bool readXMLElementFromFile (const char *xml_file_path, const char *element_name, UT_String &element_data)
 

Detailed Description

Definition at line 36 of file UT_FileUtil.h.

Member Enumeration Documentation

Enumerator
IF_EMPTY 
ALL_CONTENTS 

Definition at line 39 of file UT_FileUtil.h.

Constructor & Destructor Documentation

UT_FileUtil::UT_FileUtil ( )
inline

Definition at line 42 of file UT_FileUtil.h.

virtual UT_FileUtil::~UT_FileUtil ( )
inlinevirtual

Definition at line 43 of file UT_FileUtil.h.

Member Function Documentation

static int UT_FileUtil::copyDir ( const char *  srcname,
const char *  dstname 
)
static
static int UT_FileUtil::copyFile ( const char *  srcname,
const char *  dstname 
)
static
static int UT_FileUtil::copyFileToStream ( const char *  srcname,
std::ostream &  os 
)
static
static exint UT_FileUtil::getFileModTime ( const char *  path)
static

Returns the file modification time of the file in the given path. Returns -1 on error.

static int64 UT_FileUtil::getFileSize ( const char *  path)
static

Returns the file size of that file in the given path. Returns -1 on error.

static int UT_FileUtil::getMaxFileDescriptors ( )
static

Return the maximum number of file descriptors that are available for this process.

static exint UT_FileUtil::getRecursiveDirMaxModTime ( const char *  path)
static

Returns the latest file modification time recusively of all files in the given path including the path itself. If the given path can be a regular file. Returns -1 if no timestamps can be retrieved.

static bool UT_FileUtil::lockFile ( int  fd)
static

Locks a file for exclusive access. Will not return until the file lock is achiveved or an error occurs. Equivalent to calling writeLockFile(). Note: On Linux, if any file descriptor referring to this file is closed, the lock will be automatically be closed. Be very careful! Returns true if the file lock succeeded, and false otherwise.

static bool UT_FileUtil::makeDir ( const char *  path,
mode_t  mode = 0777,
bool  ignore_umask = false 
)
static

Make a single directory. All leading path components must exist. The function returns true if the path already exists or if the path was made.

Parameters
path
The path to create
mode
The unix file mode
ignore_umask
By default, the users umask will be used in conjunction with the mode. This parameter will force the mode to be the given value.
static bool UT_FileUtil::makeDirs ( const char *  path,
mode_t  mode = 0777,
bool  ignore_umask = false 
)
static

Make a directory and all the parent directories needed

Parameters
path
The path to create
mode
The unix file mode
ignore_umask
By default, the users umask will be used in conjunction with the mode. This parameter will force the mode to be the given value.
static int UT_FileUtil::moveFile ( const char *  srcname,
const char *  dstname 
)
static
static bool UT_FileUtil::readLockFile ( int  fd)
static

Locks a file for read access. Will not return until the file lock is achiveved or an error occurs. Note: On Linux, if any file descriptor referring to this file is closed, the lock will be automatically be closed. Be very careful! Returns true if the file lock succeeded, and false otherwise.

static bool UT_FileUtil::readXMLElementFromFile ( const char *  xml_file_path,
const char *  element_name,
UT_String element_data 
)
static

Parses the file in search of the given XML element and outputs its contents into the string argument. Returns true uppon success or false on failure.

static int UT_FileUtil::removeDir ( const char *  dname,
UT_RemoveDepth  depth = IF_EMPTY 
)
static
static int UT_FileUtil::removeFile ( const char *  fname)
static
static int UT_FileUtil::removeLinesFromFile ( const char *  fname,
const char *  prefix,
int  readonly = 0 
)
static
int UT_FileUtil::removeOverrideFiles ( const char *  newbasepath,
const char *  relpath,
const char *  fname,
const char *  english,
int  flags,
const char *  stripinfo = 0 
)
static int UT_FileUtil::resolveSymbolicLinks ( const char *  path,
UT_WorkBuffer contents,
bool  allow_dangling_link = false 
)
static

Follow the specified symbolic link to the contents, recursing if the contents are themselves another symbolic link. This method will fail if the specified path is not to a symbolic link, or if the link does not point to an existing file when allow_dangling_link is false.

virtual void UT_FileUtil::showError ( const char *  error,
int  severity = 2 
)
virtual
virtual int UT_FileUtil::showPrompt ( const char *  prompt)
virtual
static bool UT_FileUtil::unlockFile ( int  fd)
static

Unlocks a file that was locked for exclusive access with lockFile, above. Returns true if the unlock succeeded, and false otherwise.

static void UT_FileUtil::upDirectory ( char *  path,
int  levels 
)
static
static bool UT_FileUtil::writeLockFile ( int  fd)
static

Locks a file for write access. Will not return until the file lock is achiveved or an error occurs. Note: On Linux, if any file descriptor referring to this file is closed, the lock will be automatically be closed. Be very careful! Returns true if the file lock succeeded, and false otherwise.


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