Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::FilePath Class Reference

A FilePath represents a path to a file in the filesystem. More...

#include <vcf/FoundationKit/FilePath.h>

List of all members.

Public Types

enum  { DriveSeparator = L':', DirectorySeparator = L'/', ExtensionCharacter = L'.' }

Public Member Functions

 FilePath ()
 FilePath (const String &filename)
 FilePath (const FilePath &filePath)
virtual ~FilePath ()
FilePathoperator= (const FilePath &path)
 Assigns a FilePath to another.
FilePathoperator= (const String &filename)
 Assigns a string to a file path instance.
FilePathoperator+= (const String &filename)
 operator String () const
 Returns the string value of hte FilePath.
bool empty () const
 Returns whether or not the value of the FilePath is empty.
String getDriveName () const
 returns the drivename for filesystems that support them (i.e.
String getPathName (const bool &includeDriveName=false) const
 Returns the directory portion of the file name including the 'DirectorySeparator' character at the end.
String getBaseName (const bool &includeExtension=false) const
 Returns the name component of the filename (i.e without path information ).
String getExtension () const
 Returns an extension.
bool isRelativePath () const
 Tells if the filename is a relative path.
bool isDirectoryName () const
 Returns true if the filename is a directory name.
String getFileName () const
 returns the filename converted to the native format ('nix) The filename may not be a full path name.
FilePathtransformToNative ()
 Converts the FilePath filename to the format specifically used internally by the FilePath.
FilePathtransformToOSSpecific ()
 converts the filename into the format specific for the OS The filename may not be a full path name
FilePathtransformToRelativePathName (const String &workingPath=L"")
 transform the pathname into one relative to the working path
FilePathexpandRelativePathName (const String &workingPath=L"")
 transform a relative pathname into a full pathname based on the working path
std::vector< StringgetPathComponents () const
 separates a path into a vector filled by its components i.e.

Static Public Member Functions

static String getDriveSeparator ()
 Returns the string (usually a single character) that is used to separate the drive identifier from the rest of the path string.
static String getDirectorySeparator ()
 Returns the string used to separate a directory identifiers in the format used internally by the FilePath class.
static String getDirectorySeparatorOSSpecific ()
 Returns the string used to separate a directory identifiers in the format used natively by the OS.
static String getExtensionSeparator ()
static bool isRelativePath (const String &filename)
 Tells if a filename is a relative path.
static bool isDirectoryName (const String &path)
 Tells if a path is a directory name.
static String transformToNative (const String &filename)
 Returns the filename converted to the format specifically used internally by the FilePath.
static String transformToOSSpecific (const String &filename)
 Returns the filename converted to the format specific for the OS.
static String getTransformedToRelativePathName (const String &fullPath, const String &workingPath=L"")
 returns the pathname relative to the working path
static String getExpandedRelativePathName (const String &fullPath, const String &workingPath=L"")
 expand a relative pathname into a full pathname based on the working path
static std::vector< StringgetPathComponents (const String &fullpath)
 separates a path into a vector filled by its components i.e.
static String makeDirectoryName (const String &fullname, const bool &remove=false)
 Ensures a path has a 'DirectorySeparator' as its final character.
static void splitDrive (const String &fullname, String &drive, String &pathname)
 Split a full fullname into its drive and path components.
static void splitPath (const String &fullname, String &path, String &name)
 Splits a full fullname into its path and filename components.
static void splitExtension (const String &fullname, String &root, String &ext)
 Splits a full fullname into its root and extension components.
static String getDriveName (const String &fullname)
 returns the drivename for filesystems that support them (i.e.
static String getPathName (const String &fullname, const bool &includeDriveName=false)
 returns the directory portion of the file name including the 'DirectorySeparator' character at the end
static String getBaseName (const String &fullname, const bool &includeExtension=false)
 returns the name component of the filename (i.e without path information )
static String getExtension (const String &fullname)
 returns an extension.
static bool wildCharsMatchName (const String &filename, const String &wildChars)
 helper function to check if a filename matches a wildcards pattern In the current implementation wildcards include only the '*' character.

Protected Attributes

String filename_


Detailed Description

A FilePath represents a path to a file in the filesystem.

FilePath collects some static functions used to split a filename into its components, or to directly get those components. Particular attention has been given to the performance.
Beside that its an object storing a pathname in a Native ( Unix style ) format so that more complex operations can be performed without repetitions.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
DriveSeparator 
DirectorySeparator 
ExtensionCharacter 


Constructor & Destructor Documentation

VCF::FilePath::FilePath  ) 
 

VCF::FilePath::FilePath const String filename  ) 
 

VCF::FilePath::FilePath const FilePath filePath  ) 
 

virtual VCF::FilePath::~FilePath  )  [virtual]
 


Member Function Documentation

bool VCF::FilePath::empty  )  const [inline]
 

Returns whether or not the value of the FilePath is empty.

This is equivalent to a String::empty() function call.

See also:
String::empty()

FilePath & VCF::FilePath::expandRelativePathName const String workingPath = L""  )  [inline]
 

transform a relative pathname into a full pathname based on the working path

Parameters:
the working path. If not given then working path information is retrieved from the system
Returns:
the FilePath object itself

static String VCF::FilePath::getBaseName const String fullname,
const bool &  includeExtension = false
[static]
 

returns the name component of the filename (i.e without path information )

Parameters:
true to include the extension in the name

String VCF::FilePath::getBaseName const bool &  includeExtension = false  )  const [inline]
 

Returns the name component of the filename (i.e without path information ).

Parameters:
true to include the extension in the name

static String VCF::FilePath::getDirectorySeparator  )  [inline, static]
 

Returns the string used to separate a directory identifiers in the format used internally by the FilePath class.

Note that this may be different than the directory seperator used natively by the OS. For example, on a Win32 system the directory separator is the "\" character.

String VCF::FilePath::getDirectorySeparatorOSSpecific  )  [inline, static]
 

Returns the string used to separate a directory identifiers in the format used natively by the OS.

For example, on a Win32 system the directory separator is the "\" character.

static String VCF::FilePath::getDriveName const String fullname  )  [static]
 

returns the drivename for filesystems that support them (i.e.

VMS and Win32) on 'nix systems this returns an empty string The 'DriveSeparator' character is excluded

String VCF::FilePath::getDriveName  )  const [inline]
 

returns the drivename for filesystems that support them (i.e.

VMS and Win32) on 'nix systems this returns an empty string The 'DriveSeparator' character is excluded

static String VCF::FilePath::getDriveSeparator  )  [static]
 

Returns the string (usually a single character) that is used to separate the drive identifier from the rest of the path string.

For example on Win32 systems this usually returns a ":" character.

static String VCF::FilePath::getExpandedRelativePathName const String fullPath,
const String workingPath = L""
[static]
 

expand a relative pathname into a full pathname based on the working path

Parameters:
the path to transform.
the working path. From this part it is taken only the part on the left of the last DirectorySeparator to form the directory name. If not given then working path information is retrieved from the system
Returns:
the transformed string
See also:
FilePath::makeDirectoryName()

static String VCF::FilePath::getExtension const String fullname  )  [static]
 

returns an extension.

The extension is the last occurence of the "." to the end of the filename string. For example:
If the filename is : "foo/bar/baz.1.2a.text" then the return value will be ".text"

Returns:
String the file name extension including the "." character. If no extension is found returns an empty string

String VCF::FilePath::getExtension  )  const [inline]
 

Returns an extension.

The extension is the last occurence of the "." to the end of the filename string. For example:
If the filename is : "foo/bar/baz.1.2a.text" then the return value will be ".text"

Returns:
String the file name extension including the "." character. If no extension is found returns an empty string.

static String VCF::FilePath::getExtensionSeparator  )  [inline, static]
 

String VCF::FilePath::getFileName  )  const [inline]
 

returns the filename converted to the native format ('nix) The filename may not be a full path name.

Returns:
the filename

std::vector< String > VCF::FilePath::getPathComponents  )  const [inline]
 

separates a path into a vector filled by its components i.e.

the subdirectories composing the path. each one of them with the 'DirectorySeparator' character at the end Drive and filetitle are excluded.

Returns:
the vector containing the components

static std::vector<String> VCF::FilePath::getPathComponents const String fullpath  )  [static]
 

separates a path into a vector filled by its components i.e.

the subdirectories composing the path. each one of them with the 'DirectorySeparator' character at the end Drive and filetitle are excluded.

Parameters:
fullname the full filename to separate
Returns:
the vector containing the components

static String VCF::FilePath::getPathName const String fullname,
const bool &  includeDriveName = false
[static]
 

returns the directory portion of the file name including the 'DirectorySeparator' character at the end

String VCF::FilePath::getPathName const bool &  includeDriveName = false  )  const [inline]
 

Returns the directory portion of the file name including the 'DirectorySeparator' character at the end.

static String VCF::FilePath::getTransformedToRelativePathName const String fullPath,
const String workingPath = L""
[static]
 

returns the pathname relative to the working path

Parameters:
the path to transform.
the working path. From this part it is taken only the part on the left of the last DirectorySeparator to form the directory name. If not given then working path information is retrieved from the system.
Returns:
the transformed string
See also:
FilePath::makeDirectoryName()

bool VCF::FilePath::isDirectoryName  )  const [inline]
 

Returns true if the filename is a directory name.

A file name is considered a directory name if the 'DirectorySeparator' character at the end.

Returns:
true if the path is a directory name

static bool VCF::FilePath::isDirectoryName const String path  )  [static]
 

Tells if a path is a directory name.

A path is considered a directory name if the 'DirectorySeparator' character at the end. Returns true if the path is a directory name

Parameters:
path the path to check
Returns:
true if the path is a directory name

bool VCF::FilePath::isRelativePath  )  const [inline]
 

Tells if the filename is a relative path.

Returns:
true if the filename is a relative path

static bool VCF::FilePath::isRelativePath const String filename  )  [static]
 

Tells if a filename is a relative path.

Parameters:
path the path to check
Returns:
true if the filename is a relative path

static String VCF::FilePath::makeDirectoryName const String fullname,
const bool &  remove = false
[static]
 

Ensures a path has a 'DirectorySeparator' as its final character.

Under Win32 it tests against both the '/' and '\' characters. The VCF uses the convention that directory names must be terminated with a 'DirectorySeparator' character.

Parameters:
fullname the full filename
remove,false to ensure that the name has the directory character at the end, true to remove the existing directory separator at the end if present.
Returns:
the changed fullname. Which is empty if the original one was empty too.

VCF::FilePath::operator String  )  const [inline]
 

Returns the string value of hte FilePath.

This is done by simply returning the value of the filename_ member value.

FilePath& VCF::FilePath::operator+= const String filename  )  [inline]
 

FilePath& VCF::FilePath::operator= const String filename  )  [inline]
 

Assigns a string to a file path instance.

Assumes the string value is actually some valid file path

FilePath& VCF::FilePath::operator= const FilePath path  )  [inline]
 

Assigns a FilePath to another.

static void VCF::FilePath::splitDrive const String fullname,
String drive,
String pathname
[static]
 

Split a full fullname into its drive and path components.

The expression ( fullname == drive + pathname ) is invariant. Under Win32 it tests against both the '/' and '\' characters.

Parameters:
fullname the full filename to split
drive gather the drive component, which is everything ending at the last 'DirectorySeparator' character ( this one included ) drive is empty if the filesystem does not support it ( as in the 'nix' syztems ).
pathname everything after that separator ( excluded )

static void VCF::FilePath::splitExtension const String fullname,
String root,
String ext
[static]
 

Splits a full fullname into its root and extension components.

The expression ( fullname == root + ext ) is invariant. therefore ( as in Python ):

		( root, ext ) = ( 'foo', '.txt' ) when fullname = 'foo.txt'
		( root, ext ) = ( 'foo', '' ) when fullname = 'foo', instead than: ( 'foo', '.' )
		
Parameters:
fullname the full filename to split
root everything before the last 'ExtensionSeparator' character (excluded).
ext everything after that separator ( included ) The extension is empty if there is no such separator.

static void VCF::FilePath::splitPath const String fullname,
String path,
String name
[static]
 

Splits a full fullname into its path and filename components.

The expression ( fullname == path + filename ) is invariant. Under Win32 it tests against both the '/' and '\' characters.

Parameters:
fullname the full filename to split
path gather the path component, which is everything ending at the last '\' or '/' character separator ( this one included ) Path is empty if there is no such separator.
name everything after that separator ( excluded )

FilePath & VCF::FilePath::transformToNative  )  [inline]
 

Converts the FilePath filename to the format specifically used internally by the FilePath.

The format looks like:

		[<drive_letter>:]/[dir1/][dir2/][dir_n/]
		
The filename may not be a full path name
Returns:
the FilePath object itself

static String VCF::FilePath::transformToNative const String filename  )  [static]
 

Returns the filename converted to the format specifically used internally by the FilePath.

The format looks like:

		[<drive_letter>:]/[dir1/][dir2/][dir_n/]
		
The filename may not be a full path name.
Returns:
the converted string

FilePath & VCF::FilePath::transformToOSSpecific  )  [inline]
 

converts the filename into the format specific for the OS The filename may not be a full path name

Returns:
the FilePath object itself

static String VCF::FilePath::transformToOSSpecific const String filename  )  [static]
 

Returns the filename converted to the format specific for the OS.

The filename may not be a full path name

Returns:
the converted string

FilePath & VCF::FilePath::transformToRelativePathName const String workingPath = L""  )  [inline]
 

transform the pathname into one relative to the working path

Parameters:
the working path. If not given then working path information is retrieved from the system
Returns:
the FilePath object itself

static bool VCF::FilePath::wildCharsMatchName const String filename,
const String wildChars
[static]
 

helper function to check if a filename matches a wildcards pattern In the current implementation wildcards include only the '*' character.

Parameters:
fullname the full filename to separate
Returns:
the vector containing the components


Member Data Documentation

String VCF::FilePath::filename_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information