# PFilePath Class Reference

This class describes a full description for a file on the particular platform. More...

`#include <filepath.h>`

Inheritance diagram for PFilePath:

List of all members.

## Public Member Functions

Construction
| PFilePath ()
| Create a file specification object.
| PFilePath (const char *cstr)
| Create a file specification object with the specified file name.
| PFilePath (const PString &str)
| Create a file specification object with the specified file name.
| PFilePath (const PFilePath &path)
| Create a file specification object with the specified file name.
| PFilePath (const char *prefix, const char *dir)
| Create a file spec object with a generated temporary name.
PFilePath & | operator= (const PFilePath &path)
| Change the file specification object to the specified file name.
PFilePath & | operator= (const PString &str)
| Change the file specification object to the specified file name.
PFilePath & | operator= (const char *cstr)
| Change the file specification object to the specified file name.
Path addition functions
PFilePath & | operator+= (const PString &str)
| Concatenate a string to the file path, modifiying that path.
PFilePath & | operator+= (const char *cstr)
| Concatenate a C string to a path, modifiying that path.
PFilePath & | operator+= (char ch)
| Concatenate a single character to a path.
Path decoding access functions
PFilePathString | GetVolume () const
| Get the drive/volume name component of the full file specification.
PFilePathString | GetPath () const
| Get the directory path component of the full file specification.
PFilePathString | GetTitle () const
| Get the title component of the full file specification, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" this would be "FRED".
PFilePathString | GetType () const
| Get the file type of the file.
PFilePathString | GetFileName () const
| Get the actual directory entry name component of the full file specification.
PDirectory | GetDirectory () const
| Get the the directory that the file is contained in.
void | SetType (const PFilePathString &type)
| Set the type component of the full file specification, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" would become "C:\SRC\PWLIB\FRED.TXT".

## Static Public Member Functions

Miscellaneous functions
static PBoolean | IsValid (char c)
| Test if the character is valid in a filename.
static PBoolean | IsValid (const PString &str)
| Test if all the characters are valid in a filename.
static bool | IsAbsolutePath (const PString &path)
| Test if path is an absolute path or relative path.

## Protected Member Functions

virtual void | AssignContents (const PContainer &cont)
| Copy the container contents.

## Detailed Description

This class describes a full description for a file on the particular platform.

This will always uniquely identify the file on currently mounted volumes.

An empty string for a PFilePath indicates an illegal path.

The ancestor class is dependent on the platform. For file systems that are case sensitive, eg Unix, the ancestor is `PString`. For other platforms, the ancestor class is `PCaselessString`.

## Constructor & Destructor Documentation

PFilePath::PFilePath | ( |  | ) |

Create a file specification object.

PFilePath::PFilePath | ( | const char * | cstr | ) |

Create a file specification object with the specified file name.

The string passed in may be a full or partial specification for a file as determined by the platform. It is unusual for this to be a literal string, unless only the file title is specified, as that would be platform specific.

The partial file specification is translated into a canonical form which always absolutely references the file.

Parameters:

  cstr | Partial C string for file name.

PFilePath::PFilePath | ( | const PString & | str | ) |

Create a file specification object with the specified file name.

The string passed in may be a full or partial specification for a file as determined by the platform. It is unusual for this to be a literal string, unless only the file title is specified, as that would be platform specific.

The partial file specification is translated into a canonical form which always absolutely references the file.

Parameters:

  str | Partial PString for file name.

PFilePath::PFilePath | ( | const PFilePath & | path | ) |

Create a file specification object with the specified file name.

Parameters:

  path | Previous path for file name.

PFilePath::PFilePath | ( | const char * | prefix,
|  | const char * | dir |
| ) |  |  |

Create a file spec object with a generated temporary name.

The first parameter is a prefix for the filename to which a unique number is appended. The second parameter is the directory in which the file is to be placed. If this is NULL a system standard directory is used.

Parameters:

  prefix | Prefix string for file title.
  dir | Directory in which to place the file.

## Member Function Documentation

virtual void PFilePath::AssignContents | ( | const PContainer & | cont | ) | `[protected, virtual]`

Copy the container contents.

This copies the contents from one reference to another.

No duplication of contents occurs, for instance if the container is an array, the pointer to the array memory is copied, not the array memory block itself.

This function will get called by the base assignment operator.

Reimplemented from PContainer.

PDirectory PFilePath::GetDirectory | ( |  | ) | const

Get the the directory that the file is contained in.

This may be identical to `GetVolume() + GetPath()` depending on the platform. eg for DOS file "C:\SRC\PWLIB\FRED.TXT" this would be "C:\SRC\PWLIB\".

Note that for Unix platforms, this returns the {physical} path of the directory. That is all symlinks are resolved. Thus the directory returned may not be the same as the value of `GetPath()`.

Returns:
  Directory that the file is contained in.

PFilePathString PFilePath::GetFileName | ( |  | ) | const

Get the actual directory entry name component of the full file specification.

This may be identical to `GetTitle() + GetType()` or simply `GetTitle()` depending on the platform. eg for DOS file "C:\SRC\PWLIB\FRED.TXT" this would be "FRED.TXT".

Returns:
  string for the file name part of the file specification.

PFilePathString PFilePath::GetPath | ( |  | ) | const

Get the directory path component of the full file specification.

This will include leading and trailing directory separators. For example on DOS this could be "\SRC\PWLIB\", for Macintosh ":Source:PwLib:" and for Unix "/users/equivalence/src/pwlib/".

Returns:
  string for the path part of the file specification.

PFilePathString PFilePath::GetTitle | ( |  | ) | const

Get the title component of the full file specification, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" this would be "FRED".

Returns:
  string for the title part of the file specification.

PFilePathString PFilePath::GetType | ( |  | ) | const

Get the file type of the file.

Note that on some platforms this may actually be part of the full name string. eg for DOS file "C:\SRC\PWLIB\FRED.TXT" this would be ".TXT" but on the Macintosh this might be "TEXT".

Note there are standard translations from file extensions, eg ".TXT" and some Macintosh file types, eg "TEXT".

Returns:
  string for the type part of the file specification.

PFilePathString PFilePath::GetVolume | ( |  | ) | const

Get the drive/volume name component of the full file specification.

This is very platform specific. For example in DOS & NT it is the drive letter followed by a colon ("C:"), for Macintosh it is the volume name ("Untitled") and for Unix it is empty ("").

Returns:
  string for the volume name part of the file specification..

static bool PFilePath::IsAbsolutePath | ( | const PString & | path | ) | `[static]`

Test if path is an absolute path or relative path.

Parameters:

  path | path name

static PBoolean PFilePath::IsValid | ( | const PString & | str | ) | `[static]`

Test if all the characters are valid in a filename.

Returns:
  true if the character is valid for a filename.

Parameters:

  str | String to test for validity.

static PBoolean PFilePath::IsValid | ( | char | c | ) | `[static]`

Test if the character is valid in a filename.

Returns:
  true if the character is valid for a filename.

Parameters:

  c | Character to test for validity.

PFilePath& PFilePath::operator+= | ( | char | ch | ) |

Concatenate a single character to a path.

The `ch` parameter is typically a literal, eg:

            myStr += '!';

Returns:
  new string with concatenation of the object and parameter.

Reimplemented from PString.

PFilePath& PFilePath::operator+= | ( | const char * | cstr | ) |

Concatenate a C string to a path, modifiying that path.

The `cstr` parameter is typically a literal string, eg:

            myStr += "fred";

Returns:
  reference to string that was concatenated to.

Parameters:

  cstr | C string to concatenate.

Reimplemented from PString.

PFilePath& PFilePath::operator+= | ( | const PString & | str | ) |

Concatenate a string to the file path, modifiying that path.

Returns:
  reference to string that was concatenated to.

Parameters:

  str | String to concatenate.

Reimplemented from PString.

PFilePath& PFilePath::operator= | ( | const char * | cstr | ) |

Change the file specification object to the specified file name.

The string passed in may be a full or partial specifiaction for a file as determined by the platform. It is unusual for this to be a literal string, unless only the file title is specified, as that would be platform specific.

The partial file specification is translated into a canonical form which always absolutely references the file.

Parameters:

  cstr | Partial "C" string for file name.

Reimplemented from PString.

PFilePath& PFilePath::operator= | ( | const PString & | str | ) |

Change the file specification object to the specified file name.

The string passed in may be a full or partial specifiaction for a file as determined by the platform. It is unusual for this to be a literal string, unless only the file title is specified, as that would be platform specific.

The partial file specification is translated into a canonical form which always absolutely references the file.

Parameters:

  str | Partial PString for file name.

Reimplemented from PString.

PFilePath& PFilePath::operator= | ( | const PFilePath & | path | ) |

Change the file specification object to the specified file name.

Parameters:

  path | Previous path for file name.

void PFilePath::SetType | ( | const PFilePathString & | type | ) |

Set the type component of the full file specification, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" would become "C:\SRC\PWLIB\FRED.TXT".

Parameters:

  type | New type of the file.

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

- filepath.h