Detailed Description
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.
- See also:
- Path
Function Documentation
| bool Celartem::FileUtils::copyFile |
( |
const String & |
inSrc, |
|
|
const String & |
inDest, |
|
|
bool |
forceOverwrite = false | |
|
) |
| | |
This function duplicates the specified file.
- Parameters:
-
| 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. |
- Returns:
true if success, otherwise false.
Referenced by Celartem::Path::overwriteWith().
| 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.
- Parameters:
-
| inFileName | A base file name.
|
- Returns:
- The file name of the newly created temporary file.
| bool Celartem::FileUtils::deleteFile |
( |
const String & |
inFileName |
) |
|
This function delete the specified file.
- Parameters:
-
| inFileName | A file to be deleted. |
- Returns:
true if success, otherwise false.
| bool Celartem::FileUtils::doesExist |
( |
const String & |
inFileName |
) |
|
This function checks whether the specified file exists or not.
- Parameters:
-
| inFileName | A file to check the existence. |
- Returns:
true if the file exists, otherwise false.
| String Celartem::FileUtils::getCurrentDirectory |
( |
|
) |
|
This function returns the path for the current working directory.
- 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.
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- The extension.
| String Celartem::FileUtils::getFileNameFromPath |
( |
const String & |
inPathName |
) |
|
This function returns the body file name from the specified path.
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- The body file name.
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.
- Parameters:
-
| inFileName | Any relative path name of the file. |
- Returns:
- The full path name.
| String Celartem::FileUtils::getTemporaryDirectory |
( |
|
) |
|
This function returns the path for the temporary directory.
- 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.
- Parameters:
-
- Returns:
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.
- Parameters:
-
- Returns:
true if the path is a directory, otherwise false.
| 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
../ or ./ .
- 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
/ or \ is removed.
In Windows, the normalization process also does:
- It converts the file name into the long file name (if available).
- All
/ characters in the path are replaced with \ .
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- 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.
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- The result path.
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.
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- The result path.
| 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.
- Parameters:
-
| inPathName | Any path name for a file. |
- Returns:
- The result path.
| bool Celartem::FileUtils::replaceFile |
( |
const String & |
inReplacee, |
|
|
const String & |
inReplacer | |
|
) |
| | |
This function replaces one file with another.
- Parameters:
-
| inReplacee | File name that specifies the file to be replaced. |
| inReplacer | File name that specifies the file that overwrites the file. |
- Returns:
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.
- Parameters:
-
| inFileName | The file to be used as a temporary file. |
| inTemporary | true to use as a temporary file. |