FileName Class Reference

A class representing a filename. More...

#include <FileName.h++>

Collaboration diagram for FileName:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileName ()
 Construct a new, empty FileName.
 FileName (const String &path)
 Construct a new FileName for the given path.
 FileName (const String &dir, const String &filename)
 Construct a new FileName for the given directory and filename.
 FileName (const FileName &other)
 Copy constructor.
 FileName (const char *path)
 Construct a new FileName for the given path.
FileNameoperator= (const FileName &other)
 Assignment operator.
FileNameoperator= (const String &path)
 Assignment operator.
FileNameoperator= (const char *path)
 Assignment operator.
 ~FileName () throw ()
 Destructor.
String toString () const
 Get a String representation of the FileName.
String getPathName () const
 Get the full path represented by this FileName, as a String.
void setPathName (const String &path)
 Set the path for this FileName.
String getVolume () const
 Get the volume for this FileName.
void setVolume (const String &volume)
 Set the volume for this FileName.
String getDirectory () const
 Get the directory for this FileName.
void setDirectory (const String &dir)
 Set the directory for this FileName.
FileNamepushDirectory (const String &dir)
 Push a directory.
FileNamepopDirectory ()
 Pop a directory.
String getBaseName () const
 Get the base name from the FileName.
void setBaseName (const String &name)
 Set the base name for the FileName.
String getExtension () const
 Get the extension for the FileName.
void setExtension (const String &ext)
 Set the extension for the FileName.
String getFileName () const
 Get the filename for the FileName.
void setFileName (const String &name)
 Set the filename for the FileName.
bool isAbsolute () const throw ()
 Determine wheter the FileName represents an absolute or relative path.
FileNamecanonicalize ()
 Canonicalize the FileName.


Detailed Description

A class representing a filename.

The filename is composed of the following components, each of which can be individually modified:

Example: The Windows path C:\Program Files\TestProg\TestProg.exe breaks down as follows:
Volume: C:
Directory: \Program Files\TestProg\
Filename: TestProg.exe
Base name: TestProg
Extension: exe

Author:
Mark Lindner

Constructor & Destructor Documentation

FileName (  ) 

Construct a new, empty FileName.

FileName ( const String path  ) 

Construct a new FileName for the given path.

FileName ( const String dir,
const String filename 
)

Construct a new FileName for the given directory and filename.

FileName ( const FileName other  ) 

Copy constructor.

FileName ( const char *  path  ) 

Construct a new FileName for the given path.

~FileName (  )  throw ()

Destructor.


Member Function Documentation

FileName & canonicalize (  ) 

Canonicalize the FileName.

All "." components are removed and all ".." components are resolved. If there are more ".." components than literal components, an empty path will result.

String getBaseName (  )  const [inline]

Get the base name from the FileName.

String getDirectory (  )  const [inline]

Get the directory for this FileName.

String getExtension (  )  const [inline]

Get the extension for the FileName.

String getFileName (  )  const

Get the filename for the FileName.

String getPathName (  )  const

Get the full path represented by this FileName, as a String.

String getVolume (  )  const [inline]

Get the volume for this FileName.

For non-Windows systems, this will be an empty string.

bool isAbsolute (  )  const throw ()

Determine wheter the FileName represents an absolute or relative path.

Returns:
true if an absolute path, false otherwise.

FileName & operator= ( const char *  path  ) 

Assignment operator.

FileName & operator= ( const String path  ) 

Assignment operator.

FileName & operator= ( const FileName other  ) 

Assignment operator.

FileName & popDirectory (  ) 

Pop a directory.

Removes the rightmost path component from the directory component of the FileName.

FileName & pushDirectory ( const String dir  ) 

Push a directory.

The directory is added to the end of the directory component of the FileName.

Parameters:
dir The directory to push. May include multiple path components.

void setBaseName ( const String name  ) 

Set the base name for the FileName.

void setDirectory ( const String dir  ) 

Set the directory for this FileName.

void setExtension ( const String ext  ) 

Set the extension for the FileName.

void setFileName ( const String name  ) 

Set the filename for the FileName.

Parameters:
name The filename. If name contains no path separators, it simply becomes the new filename. If it begins with a path separator, the call does nothing. Otherwise, it is treated as a relative path: it is appended to the path, and then the entire path is reparsed, with the last component of name becoming the new filename.

void setPathName ( const String path  ) 

Set the path for this FileName.

void setVolume ( const String volume  ) 

Set the volume for this FileName.

On non-Windows systems, this call has no effect.

String toString (  )  const [inline]

Get a String representation of the FileName.

Equivalent to getPathName().


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

Generated on Sat Apr 17 23:03:08 2010 for libcommonc++ by  doxygen 1.5.9