Public Member Functions

Celartem::Path Class Reference

#include <cel_filepath.h>

List of all members.

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:
inFilePath The file path to be stored.
Celartem::Path::Path ( const String inFilePath  )  [inline]

This constructor initializes the instance with the specified file path.

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

This constructor initializes the instance with the specified file path.

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

This constructor initializes the instance with the specified file path.

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

This constructor initializes the instance with the specified file path.

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

This constructor initializes the instance with the specified file path.

Parameters:
inFilePath The 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:
inFilePath The 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 UChar2 inFilePath  )  [inline]

This function set the specified file path to this instance.

Parameters:
inFilePath The file path to be stored.
Returns:
Reference to this instance.
See also:
assign
Path& Celartem::Path::operator= ( const String inFilePath  )  [inline]

This function set the specified file path to this instance.

Parameters:
inFilePath The 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:
inFilePath The 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:
inFilePath The file path to be stored.
Returns:
Reference to this instance.
See also:
assign
Path& Celartem::Path::operator= ( const Path inFilePath  )  [inline]

This function duplicates the specified Path instance.

Parameters:
inFilePath The file path to be stored.
Returns:
Reference to this instance.
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:
inSrc The copy source file.
forceOverwrite if 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:
inReplacer File 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:

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:17.
Caminova Logo