Classes | |
class | DirectoryListing |
Functions | |
String | normalizePath (const String &inFileName) |
String | getFullPathName (const String &inFileName) |
String | getFileNameFromPath (const String &inPathName) |
String | getExtension (const String &inPathName) |
String | removeFileNameFromPath (const String &inPathName) |
String | removeExtensionFromPath (const String &inPathName) |
String | removeTrailingPathSeparator (const String &inPathName) |
String | combinePath (const String &inFolderPath, const String &inFileName) |
String | createTempFileName (const String &inFileName) |
String | createTempFileAndGetFullPath () |
bool | doesExist (const String &inFileName) |
bool | isDirectory (const String &inPath) |
bool | deleteFile (const String &inFileName) |
bool | copyFile (const String &inSrc, const String &inDest, bool forceOverwrite=false) |
bool | replaceFile (const String &inReplacee, const String &inReplacer) |
void | setTemporaryAttributes (const String &inFileName, bool inTemporary=true) |
String | getCurrentDirectory () |
String | getTemporaryDirectory () |
bool | isAbsolutePath (const String &inFileName) |
bool | createDirectoryTree (const String &inDirectoryName) |
Utilities for File Manipulation. You had better use Path class instead of directly using the functions provided in the namespace since it may cause some security risks.
String Celartem::FileUtils::combinePath | ( | const String & | inFolderPath, |
const String & | inFileName | ||
) |
This function combines path and filename using platform specific path separator.
inFolderPath | Folder path. |
inFileName | File name to combine to the tail of the folder path. |
bool Celartem::FileUtils::copyFile | ( | const String & | inSrc, |
const String & | inDest, | ||
bool | forceOverwrite = false |
||
) |
This function duplicates the specified file.
inSrc | File name that specifies the file to be copied. |
inDest | Destination file name. |
forceOverwrite | if the parameter is true , then this function overwrites the existing file, otherwise the function fails. |
true
if success, otherwise false
. Referenced by Celartem::Path::overwriteWith().
bool Celartem::FileUtils::createDirectoryTree | ( | const String & | inDirectoryName | ) |
This function creates the specified directory tree.
inDirectoryName | The directory to create. |
true
if the directory is created successfully; otherwise false
. String Celartem::FileUtils::createTempFileAndGetFullPath | ( | ) |
This function creates a temporary file on temporary directory and returns its full path.
String Celartem::FileUtils::createTempFileName | ( | const String & | inFileName | ) |
This function creates a temporary name that is based on the input filename. This function also creates the file to preserve the temporary name.
For example, if you pass "/foo/bar/baz"
, then it returns "/foo/bar/baz.xxx"
or something like it.
inFileName | A base file name. |
bool Celartem::FileUtils::deleteFile | ( | const String & | inFileName | ) |
This function delete the specified file.
inFileName | A file to be deleted. |
true
if success, otherwise false
. Referenced by Celartem::Path::deleteFile().
bool Celartem::FileUtils::doesExist | ( | const String & | inFileName | ) |
This function checks whether the specified file exists or not.
inFileName | A file to check the existence. |
true
if the file exists, otherwise false
. Referenced by Celartem::Path::doesExist().
String Celartem::FileUtils::getCurrentDirectory | ( | ) |
This function returns the path for the current working directory.
String Celartem::FileUtils::getExtension | ( | const String & | inPathName | ) |
This function returns the extension ".XXX" from the specified path.
inPathName | Any path name for a file. |
Referenced by Celartem::Path::getExtension().
String Celartem::FileUtils::getFileNameFromPath | ( | const String & | inPathName | ) |
This function returns the body file name from the specified path.
inPathName | Any path name for a file. |
Referenced by Celartem::Path::getBodyFileName().
String Celartem::FileUtils::getFullPathName | ( | const String & | inFileName | ) |
This function converts the partial path name (relative path) into full path name.
inFileName | Any relative path name of the file. |
String Celartem::FileUtils::getTemporaryDirectory | ( | ) |
This function returns the path for the temporary directory.
bool Celartem::FileUtils::isAbsolutePath | ( | const String & | inFileName | ) |
This function determines whether the specified file name is an absolute path by syntax checking.
Please note that it does not check the existance of the file.
inFileName | A file name. |
true
if it is an absolute file name; otherwise false
. bool Celartem::FileUtils::isDirectory | ( | const String & | inPath | ) |
This function checks whether the specified path is a directory or not.
inPath | A path to check. |
true
if the path is a directory, otherwise false
. Referenced by Celartem::Path::isDirectory().
String Celartem::FileUtils::normalizePath | ( | const String & | inFileName | ) |
This function returns the normalized path of the specified file path. A normalized path meets the following conditions: - The path does not include any \c ../ or \c ./ . - The path is an absolute path. - Any UCS-4 characters that has some aliases are mapped into a certain character code. - It can be a symblic link or shortcut; this function does not resolve any links. - Any trailing file separator \c / or \c \\ is removed. In Windows, the normalization process also does: - It converts the file name into the long file name (if available). - All \c / characters in the path are replaced with \c \\ . \param inPathName Any path name for a file. \return The normalized file name. You had better validate the file paths after normalizing them using the function. The folloing code checks the file is within the user's home directory or not.
Referenced by Celartem::Path::assign().
String Celartem::FileUtils::removeExtensionFromPath | ( | const String & | inPathName | ) |
This function removes the extension (including '.') from the specified path if exists.
inPathName | Any path name for a file. |
Referenced by Celartem::Path::removeExtension().
String Celartem::FileUtils::removeFileNameFromPath | ( | const String & | inPathName | ) |
This function removes the body file name from the specified path. If you pass "C:\foo\bar\baz" for the function, it returns "C:\foo\bar\" and never removes the last '\' from the path. On Windows, this function also works with '/' path separator.
inPathName | Any path name for a file. |
Referenced by Celartem::Path::removeFileNameFromPath().
String Celartem::FileUtils::removeTrailingPathSeparator | ( | const String & | inPathName | ) |
This function removes the traling path separator from the specified path. If you pass "C:\foo\bar\baz\" for the function, it returns "C:\foo\bar\baz". On Windows, this function also works with '/' path separator.
inPathName | Any path name for a file. |
Referenced by Celartem::Path::removeTrailingPathSeparator().
bool Celartem::FileUtils::replaceFile | ( | const String & | inReplacee, |
const String & | inReplacer | ||
) |
This function replaces one file with another.
inReplacee | File name that specifies the file to be replaced. |
inReplacer | File name that specifies the file that overwrites the file. |
true
if success, otherwise false
. Referenced by Celartem::Path::replaceWith().
void Celartem::FileUtils::setTemporaryAttributes | ( | const String & | inFileName, |
bool | inTemporary = true |
||
) |
This function optimizes the file for temporary use.
inFileName | The file to be used as a temporary file. |
inTemporary | true to use as a temporary file. |