GClasses
|
Contains some useful routines for manipulating files. More...
#include <GFile.h>
Static Public Member Functions | |
static bool | doesFileExist (const char *filename) |
returns true if the file exists | |
static bool | doesDirExist (const char *szDir) |
returns true if the directory exists | |
static bool | deleteFile (const char *szFilename) |
Deletes the specified file. Returns true iff successful. | |
static bool | removeDir (const char *szDir) |
Removes the specified directory. Fails if it is not empty. Returns true iff successful. | |
static const char * | clipPath (const char *szBuff) |
This finds the last slash in szBuff and returns a pointer to the char past that. (If there are no slashes or back-slashes, it returns szBuff) | |
static char * | clipFilename (char *szBuff) |
This finds the last slash in szBuff and sets it to '\0' and returns szBuff. | |
static bool | localStorageDirectory (char *toHere) |
returns a user's home directory for the various OS's | |
static bool | copyFile (const char *szSrcPath, const char *szDestPath) |
This copies a file. It doesn't check to see if it is overwriting--it just does the copying. On success it returns true. On error it returns false. It won't work with a file bigger than 2GB. Both paths must include the filename. | |
static char * | loadFile (const char *szFilename, size_t *pnSize) |
Loads a file into memory and returns a pointer to the memory. You must delete the buffer it returns. | |
static void | saveFile (const char *pBuf, size_t nSize, const char *szFilename) |
Saves a buffer as a file. Returns true on success. | |
static void | fileList (std::vector< std::string > &list, const char *dir=".") |
Fills "list" with the names of all the files (excluding folders) in the specified directory. | |
static void | folderList (std::vector< std::string > &list, const char *dir=".", bool excludeDots=true) |
Fills "list" with the names of all the folders in the specified directory. If excludeDots is true, then folders named "." or ".." will be excluded. | |
static bool | makeDir (const char *szDir) |
This is a brute force way to make a directory. It iterates through each subdir in szDir and calls mkdir until it has created the complete set of nested directories. | |
static void | condensePath (char *szPath) |
Remove extra ".." folders in the path. | |
static time_t | modifiedTime (const char *szFilename) |
This returns the number of seconds since 1970 UTC. | |
static void | setModifiedTime (const char *filename, time_t t) |
Set the last modified time of a file. | |
static void | parsePath (const char *szPath, struct PathData *pData) |
Identifies the folder, file, extension, and total length from a path. | |
static void | tempFilename (char *pBuf) |
returns a temporary filename |
Contains some useful routines for manipulating files.
static char* GClasses::GFile::clipFilename | ( | char * | szBuff | ) | [static] |
This finds the last slash in szBuff and sets it to '\0' and returns szBuff.
static const char* GClasses::GFile::clipPath | ( | const char * | szBuff | ) | [static] |
This finds the last slash in szBuff and returns a pointer to the char past that. (If there are no slashes or back-slashes, it returns szBuff)
static void GClasses::GFile::condensePath | ( | char * | szPath | ) | [static] |
Remove extra ".." folders in the path.
static bool GClasses::GFile::copyFile | ( | const char * | szSrcPath, |
const char * | szDestPath | ||
) | [static] |
This copies a file. It doesn't check to see if it is overwriting--it just does the copying. On success it returns true. On error it returns false. It won't work with a file bigger than 2GB. Both paths must include the filename.
static bool GClasses::GFile::deleteFile | ( | const char * | szFilename | ) | [static] |
Deletes the specified file. Returns true iff successful.
static bool GClasses::GFile::doesDirExist | ( | const char * | szDir | ) | [static] |
returns true if the directory exists
static bool GClasses::GFile::doesFileExist | ( | const char * | filename | ) | [static] |
returns true if the file exists
static void GClasses::GFile::fileList | ( | std::vector< std::string > & | list, |
const char * | dir = "." |
||
) | [static] |
Fills "list" with the names of all the files (excluding folders) in the specified directory.
static void GClasses::GFile::folderList | ( | std::vector< std::string > & | list, |
const char * | dir = "." , |
||
bool | excludeDots = true |
||
) | [static] |
Fills "list" with the names of all the folders in the specified directory. If excludeDots is true, then folders named "." or ".." will be excluded.
static char* GClasses::GFile::loadFile | ( | const char * | szFilename, |
size_t * | pnSize | ||
) | [static] |
Loads a file into memory and returns a pointer to the memory. You must delete the buffer it returns.
static bool GClasses::GFile::localStorageDirectory | ( | char * | toHere | ) | [static] |
returns a user's home directory for the various OS's
static bool GClasses::GFile::makeDir | ( | const char * | szDir | ) | [static] |
This is a brute force way to make a directory. It iterates through each subdir in szDir and calls mkdir until it has created the complete set of nested directories.
static time_t GClasses::GFile::modifiedTime | ( | const char * | szFilename | ) | [static] |
This returns the number of seconds since 1970 UTC.
static void GClasses::GFile::parsePath | ( | const char * | szPath, |
struct PathData * | pData | ||
) | [static] |
Identifies the folder, file, extension, and total length from a path.
static bool GClasses::GFile::removeDir | ( | const char * | szDir | ) | [static] |
Removes the specified directory. Fails if it is not empty. Returns true iff successful.
static void GClasses::GFile::saveFile | ( | const char * | pBuf, |
size_t | nSize, | ||
const char * | szFilename | ||
) | [static] |
Saves a buffer as a file. Returns true on success.
static void GClasses::GFile::setModifiedTime | ( | const char * | filename, |
time_t | t | ||
) | [static] |
Set the last modified time of a file.
static void GClasses::GFile::tempFilename | ( | char * | pBuf | ) | [static] |
returns a temporary filename