Public Member Functions | List of all members
Celartem::Path Class Reference

#include <cel_filepath.h>

Public Member Functions

 Path ()
 
 Path (const Path &inFilePath)
 
 Path (const String &inFilePath)
 
 Path (const char *inFilePath)
 
 Path (const utf8s &inFilePath)
 
 Path (const UChar2 *inFilePath)
 
 Path (const UChar4 *inFilePath)
 
Pathoperator= (const Path &inFilePath)
 
Pathoperator= (const String &inFilePath)
 
Pathoperator= (const utf8s &inFilePath)
 
Pathoperator= (const UChar2 *inFilePath)
 
Pathoperator= (const UChar4 *inFilePath)
 
 operator String () const
 
String getPath () const
 
void assign (const String &inFilePath)
 
String getBodyFileName () const
 
String removeFileNameFromPath () const
 
String removeTrailingPathSeparator () const
 
String getExtension () const
 
String removeExtension () const
 
bool doesExist () const
 
bool isDirectory () const
 
bool deleteFile () const
 
bool overwriteWith (const Path &inSrc, bool forceOverwrite=false) const
 
bool replaceWith (const Path &inReplacer) const
 

Detailed Description

This class ensures the file path is normalized and reduces the risk of inproper file path validation. The codes that deals with any file paths had better use the class instead of the real file path.
Almost all the member functions provided in the class uses the functions provided in FileUtils namespace.

See Also
FileUtils, FileUtils::normalizePath

Constructor & Destructor Documentation

Celartem::Path::Path ( )
inline

Default constructor.

Celartem::Path::Path ( const Path inFilePath)
inline

This constructor is for duplicating the Path instance.

Parameters
inFilePathThe file path to be stored.
Celartem::Path::Path ( const String inFilePath)
inline

This constructor initializes the instance with the specified file path.

Parameters
inFilePathThe file path to be stored.
Celartem::Path::Path ( const char *  inFilePath)
inline

This constructor initializes the instance with the specified file path.

Parameters
inFilePathThe file path to be stored.
Celartem::Path::Path ( const utf8s inFilePath)
inline

This constructor initializes the instance with the specified file path.

Parameters
inFilePathThe file path to be stored.
Celartem::Path::Path ( const UChar2 inFilePath)
inline

This constructor initializes the instance with the specified file path.

Parameters
inFilePathThe file path to be stored.
Celartem::Path::Path ( const UChar4 inFilePath)
inline

This constructor initializes the instance with the specified file path.

Parameters
inFilePathThe file path to be stored.

Member Function Documentation

void Celartem::Path::assign ( const String inFilePath)
inline

This function set the specified file path to this instance. It internally calls FileUtils::normalizePath function.

Parameters
inFilePathThe file path to be stored.

Referenced by operator=(), and Path().

bool Celartem::Path::deleteFile ( ) const
inline

This function delete the file.

Returns
true if success, otherwise false.
bool Celartem::Path::doesExist ( ) const
inline

This function checks whether the file exists or not.

Returns
true if the file exists, otherwise false.
String Celartem::Path::getBodyFileName ( ) const
inline

This function returns the body file name.
If you pass "C:\foo\bar\baz.txt" for the function, it returns "baz.txt". On Windows, this function also works with '/' path separator.

Returns
The body file name.
String Celartem::Path::getExtension ( ) const
inline

This function returns the extension ".XXX".

Returns
The extension.
String Celartem::Path::getPath ( ) const
inline

This function explicitly convert the instance into String. You can assume the file path returned is normalized.

Returns
The normalized file path.
See Also
assign
bool Celartem::Path::isDirectory ( ) const
inline

This function checks whether the specified path is a directory or not.

Returns
true if the path is a directory, otherwise false.
Celartem::Path::operator String ( ) const
inline

This function implicitly convert the instance into String. You can assume the file path returned is normalized.

Returns
The normalized file path.
See Also
assign
Path& Celartem::Path::operator= ( const Path inFilePath)
inline

This function duplicates the specified Path instance.

Parameters
inFilePathThe file path to be stored.
Returns
Reference to this instance.
Path& Celartem::Path::operator= ( const String inFilePath)
inline

This function set the specified file path to this instance.

Parameters
inFilePathThe file path to be stored.
Returns
Reference to this instance.
See Also
assign
Path& Celartem::Path::operator= ( const utf8s inFilePath)
inline

This function set the specified file path to this instance.

Parameters
inFilePathThe file path to be stored.
Returns
Reference to this instance.
See Also
assign
Path& Celartem::Path::operator= ( const UChar2 inFilePath)
inline

This function set the specified file path to this instance.

Parameters
inFilePathThe file path to be stored.
Returns
Reference to this instance.
See Also
assign
Path& Celartem::Path::operator= ( const UChar4 inFilePath)
inline

This function set the specified file path to this instance.

Parameters
inFilePathThe file path to be stored.
Returns
Reference to this instance.
See Also
assign
bool Celartem::Path::overwriteWith ( const Path inSrc,
bool  forceOverwrite = false 
) const
inline

This function overwrite the file with the specified file; it actually does copy of the specified file.

Parameters
inSrcThe copy source file.
forceOverwriteif the parameter is true, then this function overwrites the existing file, otherwise the function fails.
Returns
true if success, otherwise false.
String Celartem::Path::removeExtension ( ) const
inline

This function removes the extension (including '.').

Returns
The result path.
String Celartem::Path::removeFileNameFromPath ( ) const
inline

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.

Returns
The result path.
String Celartem::Path::removeTrailingPathSeparator ( ) const
inline

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.

Returns
The result path.
bool Celartem::Path::replaceWith ( const Path inReplacer) const
inline

This function replaces the file with another file.

Parameters
inReplacerFile name that specifies the file that overwrites the file.
Returns
true if success, otherwise false.

The documentation for this class was generated from the following file:

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo