Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Path Class Reference

#include <Directory.h>

List of all members.


Detailed Description

A path describes the position of a file or directory, absolutely or relatively.

This description consists of a root, the directories and/or file elements.

Author:
Thomas Jacob

Definition at line 604 of file Directory.h.

Public Member Functions

void AppendElement (PathElement *Element)
 Appends a path element to the path.

void AppendElement (const char *elementName)
 Appends a path element to the path.

void AppendPath (class Path *Path)
 Appends another path's elements to the path.

void AppendPath (const char *path)
 Appends another path's elements to the path.

PathClone ()
 Creates a new instance of the path with clones of the path elements.

bool Contains (class Path *Path)
 Returns whether a given path is a part of this path.

bool Contains (const char *path)
 Returns whether a given path is a part of this path.

PathCreateRelativePathTo (class Path *Path)
 Creates a new relative path from this path to another one.

PathCreateRelativePathTo (const char *path)
 Creates a new relative path from this path to another one.

PathCreateTargetPath (class Path *Path)
 Creates the path that results when navigation from this path to another path.

PathCreateTargetPath (const char *path)
 Creates the path that results when navigation from this path to another path.

void DeleteAll ()
 Deletes all path elements from the path.

bool DeleteElement (PathElement *Element)
 Deletes a given path element from the path.

bool DeleteElement (long nr)
 Deletes a path element at a given position.

bool DeleteFirstElement ()
 Deletes the first path element from the path.

bool DeleteLastElement ()
 Deletes the last path element from the path.

bool Exists ()
 Returns, if the file or directory, the path points to, exists.

PathElementGetElement (long nr)
 Returns the path element at a given position.

int GetElementCount ()
 Returns the number of path elements.

PathElementGetFirstElement ()
 Returns the first path element.

PathElementGetLastElement ()
 Returns the last path element.

char * GetRoot ()
 Returns the root of the path (e.g.

void InsertElement (PathElement *Element, long nr)
 Inserts a path element before a given position.

void InsertElement (const char *elementName, long nr)
 Inserts a path element before a given position.

bool IsAbsolute ()
 Returns, if the Root is not empty, so if the Path is absolute.

bool IsEmpty ()
 Returns, if the path elements are empty.

bool IsRelative ()
 Returns, if the Root is empty, so if the Path is relative.

bool MakeDirectory ()
 Makes a directory with the name the path points to.

 Path (const char *path)
 Creates a path from a string template.

 Path ()
 Creates an empty path.

void PrependElement (PathElement *Element)
 Prepends a path element to the path.

void PrependElement (const char *elementName)
 Prepends a path element to the path.

void PrependPath (class Path *Path)
 Prepends another path's elements to the path.

void PrependPath (const char *path)
 Prepends another path's elements to the path.

void SetRoot (const char *root)
 Sets the root for the path.

char * ToString (bool trailingSlash)
 Creates a string representing the complete path.

char * ToString ()
 Creates a string representing the complete path.

PathElementUnlinkElement (PathElement *Element)
 Removes an given element from the path.

PathElementUnlinkElement (long nr)
 Removes an element at a given position.

PathElementUnlinkFirstElement ()
 Removes the first element from the path.

PathElementUnlinkLastElement ()
 Removes the last element from the path.

 ~Path ()
 Destroys the path.


Static Public Member Functions

PathCreateApplicationFolderPath ()
 Creates a new instance of the path that points to the application (EXE) file's container folder.

PathCreateApplicationPath ()
 Creates a new instance of the path that points to the application (EXE) file.


Private Attributes

ContainingList< PathElement > * Elements
 The directories and/or file elements.

char * Root
 The root of the file or directory.


Constructor & Destructor Documentation

Path  ) 
 

Creates an empty path.

Path const char *  path  ) 
 

Creates a path from a string template.

Parameters:
path The path as a string. This string is no longer used after the construction.

~Path  ) 
 

Destroys the path.


Member Function Documentation

void AppendElement PathElement Element  )  [inline]
 

Appends a path element to the path.

Parameters:
Element The element to be appended. This element is not copied, but directly used.

void AppendElement const char *  elementName  )  [inline]
 

Appends a path element to the path.

Parameters:
elementName A string for a new path element be appended.

void AppendPath class Path Path  ) 
 

Appends another path's elements to the path.

Parameters:
Path The path to be appended. The elements are cloned, so the path is no longer used after it has been appended.

void AppendPath const char *  path  ) 
 

Appends another path's elements to the path.

Parameters:
path A string for a new path elements to be appended.

Path* Clone  ) 
 

Creates a new instance of the path with clones of the path elements.

Returns:
A clone of the object.
Exceptions:
EOutOfMemory The clone could not be allocated.

bool Contains class Path Path  ) 
 

Returns whether a given path is a part of this path.

That is, the roots are the same, and all the given path's elements match the first elements of this path.

Parameters:
Path The path that must be the prefix of this path.
Returns:
Whether a given path is a part of this path.

bool Contains const char *  path  ) 
 

Returns whether a given path is a part of this path.

That is, the roots are the same, and all the given path's elements match the first elements of this path.

Parameters:
path The path that must be the prefix of this path.
Returns:
Whether a given path is a part of this path.

Path* CreateApplicationFolderPath  )  [static]
 

Creates a new instance of the path that points to the application (EXE) file's container folder.

Returns:
The application folder path.
Exceptions:
EOutOfMemory The object could not be allocated.

Path* CreateApplicationPath  )  [static]
 

Creates a new instance of the path that points to the application (EXE) file.

Returns:
The application path.
Exceptions:
EOutOfMemory The object could not be allocated.

class Path* CreateRelativePathTo class Path Path  ) 
 

Creates a new relative path from this path to another one.

If both paths are relative, or both are absolute with the same root, the method creates a relative path from this path to the other one.
If both paths are absolute with a different root, or if this path is relative and the other one is absolute, the method creates a clone of the other (absolute) path.
If this path is absolute and the other path is relative, the method returns NULL, because a path cannot be built.

Examples:
This is foo, other path is bar.dat, result is ...dat
This is C:, other path is C:.dat, result is ...dat
This is foo, other path is C:.dat, result is C:.dat
This is C:, other path is D:.dat, result is D:.dat
This is C:, other path is bar.dat, result is NULL

Parameters:
Path The other path.
Returns:
A new Path object or NULL.
Warning:
This method allocates memory and expects, that it is freed by the caller.

Path* CreateRelativePathTo const char *  path  ) 
 

Creates a new relative path from this path to another one.

If both paths are relative, or both are absolute with the same root, the method creates a relative path from this path to the other one.
If both paths are absolute with a different root, or if this path is relative and the other one is absolute, the method creates a clone of the other (absolute) path.
If this path is absolute and the other path is relative, the method returns NULL, because a path cannot be built.

Examples:
This is foo, other path is bar.dat, result is ...dat
This is C:, other path is C:.dat, result is ...dat
This is foo, other path is C:.dat, result is C:.dat
This is C:, other path is D:.dat, result is D:.dat
This is C:, other path is bar.dat, result is NULL

Parameters:
path The other path.
Returns:
A new Path object or NULL.
Warning:
This method allocates memory and expects, that it is freed by the caller.

class Path* CreateTargetPath class Path Path  ) 
 

Creates the path that results when navigation from this path to another path.

If the other path is relative, it is appended to this path. If it is absolute, a clone of that path is returned.
The method always creates a new path.

Parameters:
Path The other path.
Returns:
The target path.
Warning:
This method allocates memory and expects, that it is freed by the caller.

class Path* CreateTargetPath const char *  path  ) 
 

Creates the path that results when navigation from this path to another path.

If the other path is relative, it is appended to this path. If it is absolute, a clone of that path is returned.
The method always creates a new path.

Parameters:
path The other path.
Returns:
The target path.
Warning:
This method allocates memory and expects, that it is freed by the caller.

void DeleteAll  )  [inline]
 

Deletes all path elements from the path.

All elements are removed from the path and freed.

bool DeleteElement PathElement Element  )  [inline]
 

Deletes a given path element from the path.

The element is searched, removed from the path and freed.

Parameters:
Element The element to be deleted.
Returns:
If the deletion was successful.

bool DeleteElement long  nr  )  [inline]
 

Deletes a path element at a given position.

The element is removed from the path and freed.

Parameters:
nr The position of the element.
Returns:
If the deletion was successful.

bool DeleteFirstElement  )  [inline]
 

Deletes the first path element from the path.

The element is removed from the path and freed.

Returns:
If the deletion was successful.

bool DeleteLastElement  )  [inline]
 

Deletes the last path element from the path.

The element is removed from the path and freed.

Returns:
If the deletion was successful.

bool Exists  ) 
 

Returns, if the file or directory, the path points to, exists.

Returns:
If the file or directory exists.

PathElement* GetElement long  nr  )  [inline]
 

Returns the path element at a given position.

Parameters:
nr The position of the element.
Returns:
The element at the position.

int GetElementCount  )  [inline]
 

Returns the number of path elements.

Returns:
The number of path elements.

PathElement* GetFirstElement  )  [inline]
 

Returns the first path element.

Returns:
The first path element.

PathElement* GetLastElement  )  [inline]
 

Returns the last path element.

Returns:
The last path element.

char* GetRoot  )  [inline]
 

Returns the root of the path (e.g.

"C:\"). If the path is relative, this is an empty string.

Returns:
The root of the path.

void InsertElement PathElement Element,
long  nr
[inline]
 

Inserts a path element before a given position.

Parameters:
Element The element to be inserted. This element is not copied, but directly used.
nr The position to insert before.

void InsertElement const char *  elementName,
long  nr
[inline]
 

Inserts a path element before a given position.

Parameters:
elementName A string for a new path element be inserted.
nr The position to insert before.

bool IsAbsolute  )  [inline]
 

Returns, if the Root is not empty, so if the Path is absolute.

Returns:
If the Path is absolute.

bool IsEmpty  )  [inline]
 

Returns, if the path elements are empty.

Returns:
If the path elements are empty.

bool IsRelative  )  [inline]
 

Returns, if the Root is empty, so if the Path is relative.

Returns:
If the Path is relative.

bool MakeDirectory  ) 
 

Makes a directory with the name the path points to.

void PrependElement PathElement Element  )  [inline]
 

Prepends a path element to the path.

Parameters:
Element The element to be prepended. This element is not copied, but directly used.

void PrependElement const char *  elementName  )  [inline]
 

Prepends a path element to the path.

Parameters:
elementName A string for a new path element be prepended.

void PrependPath class Path Path  ) 
 

Prepends another path's elements to the path.

Parameters:
Path The path to be prepended. The elements are cloned, so the path is no longer used after it has been prepended.

void PrependPath const char *  path  ) 
 

Prepends another path's elements to the path.

Parameters:
path A string for a new path elements to be prepended.

void SetRoot const char *  root  ) 
 

Sets the root for the path.

This is for example C:\. After the root has been set, it is no longer used.

Parameters:
root The new root.

char* ToString bool  trailingSlash  ) 
 

Creates a string representing the complete path.

Parameters:
trailingSlash If it shall be trailed by a back slash, if not required by the root.
Returns:
The path as string.
Warning:
This method creates memory and expects that it is freed by the caller.

char* ToString  )  [inline]
 

Creates a string representing the complete path.

It is not trailed by a back slash, if not required by the root.

Returns:
The path as string.
Warning:
This method creates memory and expects that it is freed by the caller.

PathElement* UnlinkElement PathElement Element  )  [inline]
 

Removes an given element from the path.

The element is not freed, but returned.

Parameters:
Element The element to be removed.
Returns:
The element.

PathElement* UnlinkElement long  nr  )  [inline]
 

Removes an element at a given position.

The element is not freed, but returned.

Parameters:
nr The position of the element.
Returns:
The element.

PathElement* UnlinkFirstElement  )  [inline]
 

Removes the first element from the path.

The element is not freed, but returned.

Returns:
The element.

PathElement* UnlinkLastElement  )  [inline]
 

Removes the last element from the path.

The element is not freed, but returned.

Returns:
The element.


Member Data Documentation

ContainingList<PathElement>* Elements [private]
 

The directories and/or file elements.

Definition at line 611 of file Directory.h.

char* Root [private]
 

The root of the file or directory.

This is for example C:\.

Definition at line 624 of file Directory.h.


The documentation for this class was generated from the following file:
Generated on Tue Oct 3 00:23:40 2006 for ToolBox by doxygen 1.3.6