Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

FilesUtility Class Reference

List of all members.

Static Public Member Functions

int chown (string const &filename, int uid, int gid)
int chown (const char *filename, int uid, int gid)
int completePath (string &fileName)
int completePath (char **, int *size, int dontRealloc=0)
int copyFile (string const &src, string const &dest, int overwrite)
int copyFile (const char *, const char *, int overwrite)
int deleteDirectory (string const &path)
int deleteDirectory (const char *path)
int deleteFile (string const &file)
int deleteFile (const char *)
int fileExists (string const &file)
int fileExists (const char *)
time_t getCreationTime (string const &filename)
time_t getCreationTime (const char *filename)
void getFileExt (string &ext, string const &filename)
void getFileExt (char *ext, const char *filename)
void getFilename (string const &path, string &filename)
void getFilename (const char *path, char *filename)
int getFilenameLength (const char *, int *)
time_t getLastAccTime (string const &filename)
time_t getLastAccTime (const char *filename)
time_t getLastModTime (string const &filename)
time_t getLastModTime (const char *filename)
int getPathRecursionLevel (string &filename)
int getPathRecursionLevel (const char *)
int getShortFileName (char *, char *, int)
int isDirectory (string &dir)
int isDirectory (const char *)
int isLink (string &dir)
int isLink (const char *)
int renameFile (string const &before, string const &after)
int renameFile (const char *, const char *)
int simpleMakeDirectory (string const &path)
int simpleMakeDirectory (const char *path)
void splitPath (string const &path, string &dir, string &filename)
void splitPath (const char *path, char *dir, char *filename)
void splitPathLength (const char *path, int *dir, int *filename)

Private Member Functions

 FilesUtility ()

Private Attributes

string filename
FileHandle handle

Constructor & Destructor Documentation

FilesUtility::FilesUtility  )  [private]
 

Don't allow instances for this class.


Member Function Documentation

int FilesUtility::chown string const &  filename,
int  uid,
int  gid
[static]
 

int FilesUtility::chown const char *  filename,
int  uid,
int  gid
[static]
 

Change the owner of the current file, use the value -1 for uid or gid to do not change the value. Return 0 on success.

Parameters:
filename The path to the file to chown.
uid The user id.
gid the group id.

int FilesUtility::completePath string &  fileName  )  [static]
 

Complete the path of the file. Return non-zero on errors.

Parameters:
fileName The file name to complete.

int FilesUtility::completePath char **  fileName,
int *  size,
int  dontRealloc = 0
[static]
 

Complete the path of the file. Return non-zero on errors.

Parameters:
fileName The buffer to use.
size The new buffer size.
dontRealloc Don't realloc a new buffer.

int FilesUtility::copyFile string const &  src,
string const &  dest,
int  overwrite
[static]
 

int FilesUtility::copyFile const char *  src,
const char *  dest,
int  overwrite
[static]
 

Copy the file from [SRC] to [DEST]. Returns 0 on success.

Parameters:
src The source file name.
dest The destination file name.
overwrite Overwrite the dest file if already exists?

int FilesUtility::deleteDirectory string const &  path  )  [static]
 

int FilesUtility::deleteDirectory const char *  path  )  [static]
 

Delete a directory. Return non-zero on errors.

Parameters:
path The directory to remove.

int FilesUtility::deleteFile string const &  file  )  [static]
 

int FilesUtility::deleteFile const char *  filename  )  [static]
 

Delete an existing file passing the path. Return a non-null value on errors.

Parameters:
filename The file to delete.

int FilesUtility::fileExists string const &  file  )  [static]
 

int FilesUtility::fileExists const char *  filename  )  [static]
 

Returns a non-null value if the given path is a valid file.

Parameters:
filename The path to check.

time_t FilesUtility::getCreationTime string const &  filename  )  [static]
 

time_t FilesUtility::getCreationTime const char *  filename  )  [static]
 

Returns the time of the file creation. Returns -1 on errors.

Parameters:
filename The path to check.

void FilesUtility::getFileExt string &  ext,
string const &  filename
[static]
 

Get the file extension passing its path. Save in ext all the bytes afer the last dot(.) in filename.

Parameters:
ext The buffer to fullfill with the file extension.
filename The path to the file.

void FilesUtility::getFileExt char *  ext,
const char *  filename
[static]
 

Get the file extension passing its path. Save in ext all the bytes afer the last dot(.) in filename.

Parameters:
ext The buffer to fullfill with the file extension.
filename The path to the file.

void FilesUtility::getFilename string const &  path,
string &  filename
[static]
 

Get the filename from a path.

Parameters:
path The full path to the file.
filename A buffer to fullfill with the file name.

void FilesUtility::getFilename const char *  path,
char *  filename
[static]
 

Get the filename from a path. Be sure that the filename buffer is at least getFilenameLength(...) bytes before call this function.

Parameters:
path The full path to the file.
filename A buffer to fullfill with the file name.

int FilesUtility::getFilenameLength const char *  path,
int *  filename
[static]
 

Get the length of the file in the path.

Parameters:
path The full path where get the filename length.
filename A pointer to the start of the file name.

time_t FilesUtility::getLastAccTime string const &  filename  )  [static]
 

time_t FilesUtility::getLastAccTime const char *  filename  )  [static]
 

Returns the time of the last access to the file. Returns -1 on errors.

Parameters:
filename The path to check.

time_t FilesUtility::getLastModTime string const &  filename  )  [static]
 

time_t FilesUtility::getLastModTime const char *  filename  )  [static]
 

Returns the time of the last modify to the file. Returns -1 on errors.

Parameters:
filename The path to check.

int FilesUtility::getPathRecursionLevel string &  filename  )  [static]
 

int FilesUtility::getPathRecursionLevel const char *  path  )  [static]
 

This funtion iterates through every character of the path The first IF tries to clear out the bars, if it finds one, just advances one character and starts the cycle again The second IF tries to find at least two dots. if it finds only 1, does nothing, WIN32 if it finds 2 or more rec=rec-(number of dots -1) UNIX if it finds 2, decrements rec, if it finds more, increments it considering it's a name if it ends with something else other then a bar of a NULL, then it's a path of the form "/...qwerty/" that should be considered rec++ The last ELSE, catches the rest and advances to the next bar. Return the recursion of the path.

Parameters:
path The file name.

int FilesUtility::getShortFileName char *  filePath,
char *  out,
int  buffersize
[static]
 

Get the file path in the short form of the specified file Return -1 on errors.

Parameters:
filePath The path to use.
out The buffer where write.
buffersize The buffer length.

int FilesUtility::isDirectory string &  dir  )  [static]
 

int FilesUtility::isDirectory const char *  filename  )  [static]
 

Returns a non-null value if the path is a directory.

Parameters:
filename The path to check.

int FilesUtility::isLink string &  dir  )  [static]
 

int FilesUtility::isLink const char *  filename  )  [static]
 

Returns a non-null value if the given path is a link.

Parameters:
filename The path to check.

int FilesUtility::renameFile string const &  before,
string const &  after
[static]
 

int FilesUtility::renameFile const char *  before,
const char *  after
[static]
 

Rename the file [BEFORE] to [AFTER]. Returns 0 on success.

Parameters:
before The old file name.
after The new file name.

int FilesUtility::simpleMakeDirectory string const &  path  )  [static]
 

int FilesUtility::simpleMakeDirectory const char *  path  )  [static]
 

Create a new directory. Return non-zero on errors.

Parameters:
path The path to the directory to create.

void FilesUtility::splitPath string const &  path,
string &  dir,
string &  filename
[static]
 

Split a path in a dir and a filename.

Parameters:
path The full path to the file.
dir The directory part of the path.
filename A buffer to fullfill with the file name.

void FilesUtility::splitPath const char *  path,
char *  dir,
char *  filename
[static]
 

Splits a file path into a directory and filename. Path is an input value while dir and filename are the output values.

Parameters:
path The full path to the file.
dir The directory part of the path.
filename A buffer to fullfill with the file name.

void FilesUtility::splitPathLength const char *  path,
int *  dir,
int *  filename
[static]
 

Use this function before call splitPath to be sure that the buffers dir and filename are bigger enough to contain the data.

Parameters:
path The full path to the file.
dir The directory part length of the path.
filename The length of the buffer needed to contain the file name.


Member Data Documentation

string FilesUtility::filename [private]
 

FileHandle FilesUtility::handle [private]
 


Generated on Wed Jun 11 06:31:06 2008 for MyServer by  doxygen 1.3.9.1