vtdata library
Classes | Typedefs | Functions
FilePath.h File Reference

Classes

class  dir_iter
 

Typedefs

typedef void BZFILE
 

Functions

vtString FindFileOnPaths (const vtStringArray &paths, const char *filename)
 
bool vtCreateDir (const char *dirname)
 
void vtDestroyDir (const char *dirname)
 
void vtDeleteFile (const char *filename)
 
const char * StartOfFilename (const char *szFullPath)
 
vtString ExtractPath (const char *szFullPath, bool bTrailingSlash)
 
bool PathIsAbsolute (const char *szPath)
 
vtString PathLevelUp (const char *src)
 
vtString get_line_from_stream (std::ifstream &input)
 
void RemoveFileExtensions (vtString &fname, bool bAll=true)
 
vtString GetExtension (const vtString &fname, bool bFull=true)
 
vtString ChangeFileExtension (const char *input, const char *extension)
 
bool vtFileExists (const char *fname)
 
int GetFileSize (const char *fname)
 
void SetEnvironmentVar (const vtString &var, const vtString &value)
 
bool gfopen (GZOutput &out, const char *fname)
 
int gfprintf (GZOutput &out, const char *pFormat,...)
 
void gfclose (GZOutput &out)
 
gzFile vtGZOpen (const char *path, const char *mode)
 
FILE * vtFileOpen (const char *fname_utf8, const char *mode)
 
FILE * vtFileOpen (wchar_t *fname_wide, const char *mode)
 
FILE * vtFileOpen (const std::wstring &fname_ws, const char *mode)
 

Function Documentation

vtString ExtractPath ( const char *  szFullPath,
bool  bTrailingSlash 
)

Given a full path containing a filename, return a string containing just the path portion of the string.

Parameters
szFullPathThe full path.
bTrailingSlashIf true, include the trailing slash, if present. Example Input: "/usr/data/file.txt" Output: /usr/data/" with trailing slash, "/usr/data" without.
vtString FindFileOnPaths ( const vtStringArray &  paths,
const char *  filename 
)

This function will search for a given file on the given paths, returning the full path to the first file which is found (file exists and can be read from).

Parameters
pathsAn array of strings containing the directories to search. Each directory should end with a the trailing slash ("/" or "\")
filenameA filename, which can optionally contain a partial path as well. Examples: "foo.txt" or "Stuff/foo.txt" Note: encoding of this filename is assumed to be UTF-8!
vtString GetExtension ( const vtString fname,
bool  bFull 
)

Get the full file extension(s) from a filename.

bool PathIsAbsolute ( const char *  szPath)

Return whether a path is absolute or relative.

vtString PathLevelUp ( const char *  src)

Given a path like "C:/bar/foo", returns the path a level up, like "C:/bar"

void RemoveFileExtensions ( vtString fname,
bool  bAll 
)

Given a filename (which may include a path), remove any file extension(s) which it may have.

const char* StartOfFilename ( const char *  szFullPath)

Given a full path containing a filename, return a pointer to the filename portion of the string.

bool vtCreateDir ( const char *  dirname)

Recursive make directory. Aborts if there is an ENOENT error somewhere in the middle.

Parameters
dirnameThe full page to directory to be created, in utf-8 encoding.
Returns
true if OK, false on error
void vtDeleteFile ( const char *  filename)

Delete a file.

void vtDestroyDir ( const char *  dirname)

Destroy a directory and all its contents (recusively if needed).

FILE* vtFileOpen ( const char *  fname_utf8,
const char *  mode 
)

Open a file using a UTF-8 encoded filename.

Parameters are the same as fopen(). The only difference is that instead of being limited to multi-byte local charset, it is UTF-8 which supports all languages.

FILE* vtFileOpen ( wchar_t *  fname_wide,
const char *  mode 
)

Open a file using a wide-character (i.e. Unicode) filename.

Parameters are the same as fopen(). The only difference is that instead of being limited to multi-byte local charset, it is Unicode which supports all languages.

FILE* vtFileOpen ( const wstring &  fname_ws,
const char *  mode 
)

Open a file using a UTF-8 encoded filename.

Parameters are the same as fopen(). The only difference is that instead of being limited to multi-byte local charset, it is Unicode which supports all languages.