PDirectory Class Reference

Class to represent a directory in the operating system file system. More...

`#include <pdirect.h>`

Inheritance diagram for PDirectory:

## Public Member Functions

Construction
| PDirectory ()
| Create a directory object of the current working directory. More...
| PDirectory (const char *cpathname)
| Create a directory object of the specified directory. More...
| PDirectory (const PString &pathname)
| Create a directory object of the specified directory. More...
PDirectory & | operator= (const PString &pathname)
| Set the directory to the specified path. More...
PDirectory & | operator= (const char *cpathname)
| Set the directory to the specified path. More...
Directory listing functions
virtual PBoolean | Open (int scanMask=PFileInfo::AllFiles)
| Open the directory for scanning its list of files. More...
virtual PBoolean | Restart (int scanMask=PFileInfo::AllFiles)
| Restart file list scan from the beginning of directory. More...
PBoolean | Next ()
| Move to the next file in the directory scan. More...
virtual void | Close ()
| Close the directory during or after a file list scan. More...
virtual PFilePathString | GetEntryName () const
| Get the name (without the volume or directory path) of the current entry in the directory scan. More...
virtual PBoolean | IsSubDir () const
| Determine if the directory entry currently being scanned is itself another directory entry. More...
virtual PBoolean | GetInfo (PFileInfo &info) const
| Get file information on the current directory entry. More...
Public Member Functions inherited from PString
virtual PObject * | Clone () const
| Make a complete duplicate of the string. More...
virtual Comparison | Compare (const PObject &obj) const
| Get the relative rank of the two strings. More...
virtual void | PrintOn (ostream &strm) const
| Output the string to the specified stream. More...
virtual void | ReadFrom (istream &strm)
| Input the string from the specified stream. More...
virtual PINDEX | HashFunction () const
| Calculate a hash value for use in sets and dictionaries. More...
virtual PBoolean | SetSize (PINDEX newSize)
| Set the size of the string. More...
virtual PBoolean | IsEmpty () const
| Determine if the string is empty. More...
virtual PBoolean | MakeUnique ()
| Make this instance to be the one and only reference to the container contents. More...
PBoolean | MakeMinimumSize ()
| Set the actual memory block array size to the minimum required to hold the current string contents. More...
PINLINE PINDEX | GetLength () const
| Determine the length of the null terminated string. More...
bool | operator! () const
| Determine if the string is NOT empty. More...
bool | operator*= (const PString &str) const
| Compare two strings using case insensitive comparison. More...
bool | operator== (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator!= (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator< (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator> (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator<= (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator>= (const PObject &str) const
| Compare two strings using the `PObject::Compare()` function. More...
bool | operator*= (const char *cstr) const
| Compare a PString to a C string using a case insensitive compare function. More...
bool | operator== (const char *cstr) const
| Compare a PString to a C string using the `Compare()` function. More...
bool | operator!= (const char *cstr) const
| Compare a PString to a C string using the `PObject::Compare()` function. More...
bool | operator< (const char *cstr) const
| Compare a PString to a C string using the `PObject::Compare()` function. More...
bool | operator> (const char *cstr) const
| Compare a PString to a C string using the `PObject::Compare()` function. More...
bool | operator<= (const char *cstr) const
| Compare a PString to a C string using the `PObject::Compare()` function. More...
bool | operator>= (const char *cstr) const
| Compare a PString to a C string using the `PObject::Compare()` function. More...
Comparison | NumCompare (const PString &str, PINDEX count=P_MAX_INDEX, PINDEX offset=0) const
| Compare a string against a substring of the object. More...
Comparison | NumCompare (const char *cstr, PINDEX count=P_MAX_INDEX, PINDEX offset=0) const
| Compare a string against a substring of the object. More...
PINDEX | Find (char ch, PINDEX offset=0) const
| Locate the position within the string of the character. More...
PINDEX | Find (const PString &str, PINDEX offset=0) const
| Locate the position within the string of the substring. More...
PINDEX | Find (const char *cstr, PINDEX offset=0) const
PINDEX | FindLast (char ch, PINDEX offset=P_MAX_INDEX) const
| Locate the position of the last matching character. More...
PINDEX | FindLast (const PString &str, PINDEX offset=P_MAX_INDEX) const
| Locate the position of the last matching substring. More...
PINDEX | FindLast (const char *cstr, PINDEX offset=P_MAX_INDEX) const
| Locate the position of the last matching substring. More...
PINDEX | FindOneOf (const PString &set, PINDEX offset=0) const
| Locate the position of one of the characters in the set. More...
PINDEX | FindOneOf (const char *cset, PINDEX offset=0) const
| Locate the position of one of the characters in the set. More...
PINDEX | FindSpan (const PString &set, PINDEX offset=0) const
| Locate the position of character not in the set. More...
PINDEX | FindSpan (const char *cset, PINDEX offset=0) const
| Locate the position of character not in the set. More...
PINDEX | FindRegEx (const PRegularExpression &regex, PINDEX offset=0) const
| Locate the position within the string of one of the regular expression. More...
PBoolean | FindRegEx (const PRegularExpression &regex, PINDEX &pos, PINDEX &len, PINDEX offset=0, PINDEX maxPos=P_MAX_INDEX) const
| Locate the position within the string of one of the regular expression. More...
PBoolean | MatchesRegEx (const PRegularExpression &regex) const
| Return true if the entire string matches the regular expression. More...
void | Replace (const PString &target, const PString &subs, PBoolean all=false, PINDEX offset=0)
| Locate the substring within the string and replace it with the specifed substring. More...
void | Splice (const PString &str, PINDEX pos, PINDEX len=0)
| Splice the string into the current string at the specified position. More...
void | Splice (const char *cstr, PINDEX pos, PINDEX len=0)
| Splice the string into the current string at the specified position. More...
void | Delete (PINDEX start, PINDEX len)
| Remove the substring from the string. More...
PString | operator() (PINDEX start, PINDEX end) const
| Extract a portion of the string into a new string. More...
PString | Left (PINDEX len) const
| Extract a portion of the string into a new string. More...
PString | Right (PINDEX len) const
| Extract a portion of the string into a new string. More...
PString | Mid (PINDEX start, PINDEX len=P_MAX_INDEX) const
| Extract a portion of the string into a new string. More...
PString | LeftTrim () const
| Create a string consisting of all characters from the source string except all spaces at the beginning of the string. More...
PString | RightTrim () const
| Create a string consisting of all characters from the source string except all spaces at the end of the string. More...
PString | Trim () const
| Create a string consisting of all characters from the source string except all spaces at the beginning and end of the string. More...
PString | ToLower () const
| Create a string consisting of all characters from the source string with all upper case letters converted to lower case. More...
PString | ToUpper () const
| Create a string consisting of all characters from the source string with all lower case letters converted to upper case. More...
PStringArray | Tokenise (const PString &separators, PBoolean onePerSeparator=true) const
| Split the string into an array of substrings. More...
PStringArray | Tokenise (const char *cseparators, PBoolean onePerSeparator=true) const
| Split the string into an array of substrings. More...
PStringArray | Lines () const
| Split the string into individual lines. More...
PINLINE | PString ()
| Construct an empty string. More...
PINLINE | PString (const PString &str)
| Create a new reference to the specified string. More...
PINLINE | PString (const std::string &str)
| Create a new string from the specified std::string. More...
| PString (const char *cstr)
| Create a string from the C string array. More...
| PString (const wchar_t *ustr)
| Create a string from the UCS-2 string array. More...
| PString (const char *cstr, PINDEX len)
| Create a string from the array. More...
| PString (const wchar_t *ustr, PINDEX len)
| Create a string from the UCS-2 array. More...
| PString (const PWCharArray &ustr)
| Create a string from the UCS-2 array. More...
| PString (char ch)
| Create a string from the single character. More...
| PString (short n)
| Create a string from the integer type. More...
| PString (unsigned short n)
| Create a string from the integer type. More...
| PString (int n)
| Create a string from the integer type. More...
| PString (unsigned int n)
| Create a string from the integer type. More...
| PString (long n)
| Create a string from the integer type. More...
| PString (unsigned long n)
| Create a string from the integer type. More...
| PString (PInt64 n)
| Create a string from the integer type. More...
| PString (PUInt64 n)
| Create a string from the integer type. More...
| PString (ConversionType type, const char *str,...)
| PString (ConversionType type, long value, unsigned base=10)
| PString (ConversionType type, double value, unsigned places)
PString & | operator= (const PString &str)
| Assign the string to the current object. More...
PString & | operator= (const std::string &str)
| Assign the string to the current object. More...
PString & | operator= (const char *cstr)
| Assign the C string to the current object. More...
PString & | operator= (char ch)
| Assign the character to the current object. More...
PString & | operator= (short n)
| Assign a string from the integer type. More...
PString & | operator= (unsigned short n)
| Assign a string from the integer type. More...
PString & | operator= (int n)
| Assign a string from the integer type. More...
PString & | operator= (unsigned int n)
| Assign a string from the integer type. More...
PString & | operator= (long n)
| Assign a string from the integer type. More...
PString & | operator= (unsigned long n)
| Assign a string from the integer type. More...
PString & | operator= (PInt64 n)
| Assign a string from the integer type. More...
PString & | operator= (PUInt64 n)
| Assign a string from the integer type. More...
virtual PString & | MakeEmpty ()
| Make the current string empty. More...
PString | operator+ (const PString &str) const
| Concatenate two strings to produce a third. More...
PString | operator+ (const char *cstr) const
| Concatenate a C string to a PString to produce a third. More...
PString | operator+ (char ch) const
| Concatenate a single character to a PString to produce a third. More...
PString & | operator+= (const PString &str)
| Concatenate a string to another string, modifiying that string. More...
PString & | operator+= (const char *cstr)
| Concatenate a C string to a PString, modifiying that string. More...
PString & | operator+= (char ch)
| Concatenate a single character to a PString. More...
PString | operator & (const PString &str) const
| Concatenate two strings to produce a third. More...
PString | operator & (const char *cstr) const
| Concatenate a C string to a PString to produce a third. More...
PString | operator & (char ch) const
| Concatenate a single character to a PString to produce a third. More...
PString & | operator &= (const PString &str)
| Concatenate a string to another string, modifiying that string. More...
PString & | operator &= (const char *cstr)
| Concatenate a C string to a PString, modifiying that string. More...
PString & | operator &= (char ch)
| Concatenate a character to a PString, modifiying that string. More...
PString & | sprintf (const char *cfmt,...)
| Concatenate a formatted output to the string. More...
PString & | vsprintf (const PString &fmt, va_list args)
| Concatenate a formatted output to the string. More...
PString & | vsprintf (const char *cfmt, va_list args)
| Concatenate a formatted output to the string. More...
long | AsInteger (unsigned base=10) const
| Convert the string to an integer value using the specified number base. More...
DWORD | AsUnsigned (unsigned base=10) const
| Convert the string to an integer value using the specified number base. More...
PInt64 | AsInt64 (unsigned base=10) const
| Convert the string to an integer value using the specified number base. More...
PUInt64 | AsUnsigned64 (unsigned base=10) const
| Convert the string to an integer value using the specified number base. More...
double | AsReal () const
| Convert the string to a floating point number. More...
PWCharArray | AsUCS2 () const
| Convert UTF-8 string to UCS-2. More...
PBYTEArray | ToPascal () const
| Convert a standard null terminated string to a "pascal" style string. More...
PString | ToLiteral () const
| Convert the string to C literal string format. More...
| operator const unsigned char * () const
| Get the internal buffer as a pointer to unsigned characters. More...
| operator std::string () const
| Cast the PString to a std::string. More...
Public Member Functions inherited from PCharArray
| PCharArray (PINDEX initialSize=0)
| Construct a new dynamic array of char. More...
| PCharArray (char const *buffer, PINDEX length, PBoolean dynamic=true)
| Construct a new dynamic array of char. More...
Public Member Functions inherited from PBaseArray< T >
| PBaseArray (PINDEX initialSize=0)
| Construct a new dynamic array of elements of the specified type. More...
| PBaseArray (T const *buffer, PINDEX length, PBoolean dynamic=true)
| Construct a new dynamic array of elements of the specified type. More...
PBoolean | SetAt (PINDEX index, T val)
| Set the specific element in the array. More...
T | GetAt (PINDEX index) const
| Get a value from the array. More...
void | Attach (const T *buffer, PINDEX bufferSize)
| Attach a pointer to a static block to the base array type. More...
T * | GetPointer (PINDEX minSize=0)
| Get a pointer to the internal array and assure that it is of at least the specified size. More...
T | operator[] (PINDEX index) const
| Get a value from the array. More...
T & | operator[] (PINDEX index)
| Get a reference to value from the array. More...
| operator T const * () const
| Get a pointer to the internal array. More...
PBoolean | Concatenate (const PBaseArray &array)
| Concatenate one array to the end of this array. More...
Public Member Functions inherited from PAbstractArray
| PAbstractArray (PINDEX elementSizeInBytes, PINDEX initialSize=0)
| Create a new dynamic array of `initalSize` elements of `elementSizeInBytes` bytes each. More...
| PAbstractArray (PINDEX elementSizeInBytes, const void *buffer, PINDEX bufferSizeInElements, PBoolean dynamicAllocation)
| Create a new dynamic array of `bufferSizeInElements` elements of `elementSizeInBytes` bytes each. More...
void | Attach (const void *buffer, PINDEX bufferSize)
| Attach a pointer to a static block to the base array type. More...
void * | GetPointer (PINDEX minSize=1)
| Get a pointer to the internal array and assure that it is of at least the specified size. More...
PBoolean | Concatenate (const PAbstractArray &array)
| Concatenate one array to the end of this array. More...
Public Member Functions inherited from PContainer
| PContainer (PINDEX initialSize=0)
| Create a new unique container. More...
| PContainer (const PContainer &cont)
| Create a new refernce to container. More...
PContainer & | operator= (const PContainer &cont)
| Assign one container reference to another. More...
virtual | ~PContainer ()
| Destroy the container class. More...
virtual PINDEX | GetSize () const
| Get the current size of the container. More...
PBoolean | SetMinSize (PINDEX minSize)
| Set the minimum size of container. More...
PBoolean | IsUnique () const
| Determine if container is unique reference. More...
Public Member Functions inherited from PObject
virtual | ~PObject ()
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...

## Protected Member Functions

void | Construct ()
void | Destruct ()
Protected Member Functions inherited from PString
void | InternalFromUCS2 (const wchar_t *ptr, PINDEX len)
virtual Comparison | InternalCompare (PINDEX offset, char c) const
virtual Comparison | InternalCompare (PINDEX offset, PINDEX length, const char *cstr) const
| PString (int dummy, const PString *str)
| PString (PContainerReference &reference)
Protected Member Functions inherited from PBaseArray< T >
virtual void | PrintElementOn (ostream &stream, PINDEX index) const
| PBaseArray (PContainerReference &reference)
Protected Member Functions inherited from PAbstractArray
PBoolean | InternalSetSize (PINDEX newSize, PBoolean force)
virtual void | ReadElementFrom (istream &stream, PINDEX index)
| PAbstractArray (PContainerReference &reference, PINDEX elementSizeInBytes)
Protected Member Functions inherited from PContainer
| PContainer (int dummy, const PContainer *cont)
| Constructor used in support of the Clone() function. More...
| PContainer (PContainerReference &reference)
| Construct using static PContainerReference. More...
virtual void | DestroyContents ()=0
| Destroy the container contents. More...
virtual void | AssignContents (const PContainer &c)
| Copy the container contents. More...
void | CopyContents (const PContainer &c)
| Copy the container contents. More...
void | CloneContents (const PContainer *src)
| Create a duplicate of the container contents. More...
void | Destruct ()
| Internal function called from container destructors. More...
virtual void | DestroyReference ()
| Destroy the PContainerReference instance. More...
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes

int | scanMask
| Mask of file types that the directory scan will return. More...
DIR * | directory
PFileInfo * | entryInfo
struct dirent * | entryBuffer
Protected Attributes inherited from PAbstractArray
PINDEX | elementSize
| Size of an element in bytes. More...
char * | theArray
| Pointer to the allocated block of memory. More...
PBoolean | allocatedDynamically
| Flag indicating the array was allocated on the heap. More...
Protected Attributes inherited from PContainer
PContainerReference * | reference

## Access functions

PDirectory | GetParent () const
| Get the directory for the parent to the current directory. More...
PFilePathString | GetVolume () const
| Get the volume name that the directory is in. More...
PBoolean | IsRoot () const
| Determine if the directory is the root directory of a volume. More...
PDirectory | GetRoot () const
| Get the root directory of a volume. More...
PStringArray | GetPath () const
| Get the directory path as an array of strings. More...
PBoolean | GetVolumeSpace (PInt64 &total, PInt64 &free, DWORD &clusterSize) const
| Determine the total number of bytes and number of bytes free on the volume that this directory is contained on. More...
static PINLINE PBoolean | IsSeparator (char ch)
| Determine if the character `ch` is a directory path separator. More...

## File system functions

PBoolean | Exists () const
| Test for if the directory exists. More...
PBoolean | Change () const
| Change the current working directory to the objects location. More...
PBoolean | Create (int perm=PFileInfo::DefaultDirPerms) const
| Create a new directory with the specified permissions. More...
PBoolean | Remove ()
| Delete the directory. More...
static PBoolean | Exists (const PString &path)
| Test for if the specified directory exists. More...
static PBoolean | Change (const PString &path)
| Change the current working directory to that specified. More...
static PBoolean | Create (const PString &p, int perm=PFileInfo::DefaultDirPerms)
| Create a new directory as specified with the specified permissions. More...
static PBoolean | Remove (const PString &path)
| Delete the specified directory. More...

## Additional Inherited Members

Public Types inherited from PString
typedef const char * | Initialiser
enum | ConversionType { Pascal, Basic, Literal, Signed, Unsigned, Decimal, Exponent, Printf, NumConversionTypes }
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...
Static Public Member Functions inherited from PString
static PString | Empty ()
| Return an empty string. More...
Static Public Member Functions inherited from PObject
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
static const char * | Class ()
| Get the name of the class as a C string. More...

## Detailed Description

Class to represent a directory in the operating system file system.

A directory is a special file that contains a list of file paths.

The directory paths are highly platform dependent and a minimum number of assumptions should be made.

The PDirectory object is a string consisting of a possible volume name, and a series directory names in the path from the volumes root to the directory that the object represents. Each directory is separated by the platform dependent separator character which is defined by the PDIR_SEPARATOR macro. The path always has a trailing separator.

Some platforms allow more than one character to act as a directory separator so when doing any processing the `IsSeparator()` function should be used to determine if a character is a possible separator.

The directory may be opened to gain access to the list of files that it contains. Note that the directory does {not} contain the "." and ".." entries that some platforms support.

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

## PDirectory() [1/3]

PDirectory::PDirectory | ( |  | ) |

Create a directory object of the current working directory.

## PDirectory() [2/3]

PDirectory::PDirectory | ( | const char * | cpathname | ) |

Create a directory object of the specified directory.

The `cpathname` parameter may be a relative directory which is made absolute by the creation of the `PDirectory` object.

Parameters

  cpathname | Directory path name for new object.

## PDirectory() [3/3]

PDirectory::PDirectory | ( | const PString & | pathname | ) |

Create a directory object of the specified directory.

The `pathname` parameter may be a relative directory which is made absolute by the creation of the `PDirectory` object.

Parameters

  pathname | Directory path name for new object.

## Member Function Documentation

## Change() [1/2]

PBoolean PDirectory::Change | ( |  | ) | const

Change the current working directory to the objects location.

Returns
  true if current working directory was changed.

## Change() [2/2]

static PBoolean PDirectory::Change | ( | const PString & | path | ) |

static

Change the current working directory to that specified.

Returns
  true if current working directory was changed.

Parameters

  path | Directory file path.

## Close()

virtual void PDirectory::Close | ( |  | ) |

virtual

Close the directory during or after a file list scan.

## Construct()

void PDirectory::Construct | ( |  | ) |

protected

## Create() [1/2]

PBoolean PDirectory::Create | ( | int | perm = `PFileInfo::DefaultDirPerms` | ) | const

Create a new directory with the specified permissions.

Returns
  true if directory created.

## Create() [2/2]

static PBoolean PDirectory::Create | ( | const PString & | p,
|  | int | perm = `PFileInfo::DefaultDirPerms`
| ) |  |

static

Create a new directory as specified with the specified permissions.

Returns
  true if directory created.

Parameters

  p | Directory file path.
  perm | Permission on new directory.

## Destruct()

void PDirectory::Destruct | ( |  | ) |

inline protected

References PContainer::Destruct().

## Exists() [1/2]

PBoolean PDirectory::Exists | ( |  | ) | const

Test for if the directory exists.

Returns
  true if directory exists.

## Exists() [2/2]

static PBoolean PDirectory::Exists | ( | const PString & | path | ) |

static

Test for if the specified directory exists.

Returns
  true if directory exists.

Parameters

  path | Directory file path.

## GetEntryName()

virtual PFilePathString PDirectory::GetEntryName | ( |  | ) | const

virtual

Get the name (without the volume or directory path) of the current entry in the directory scan.

This may be the name of a file or a subdirectory or even a link or device for operating systems that support them.

To get a full path name concatenate the PDirectory object itself with the entry name.

Note that the directory scan will {not} return the "." and ".." entries that some platforms support.

Returns
  string for directory entry.

Referenced by PLoadPluginDirectory().

## GetInfo()

virtual PBoolean PDirectory::GetInfo | ( | PFileInfo & | info | ) | const

virtual

Get file information on the current directory entry.

Returns
  true if file information was successfully retrieved.

Parameters

  info | Object to receive the file information.

## GetParent()

PDirectory PDirectory::GetParent | ( |  | ) | const

Get the directory for the parent to the current directory.

If the directory is already the root directory it returns the root directory again.

Returns
  parent directory.

## GetPath()

PStringArray PDirectory::GetPath | ( |  | ) | const

Get the directory path as an array of strings.

The first element in the array is the volume string, eg under Win32 it is "c:" or "\\machine", while under unix it is an empty string.

## GetRoot()

PDirectory PDirectory::GetRoot | ( |  | ) | const

Get the root directory of a volume.

Returns
  root directory.

## GetVolume()

PFilePathString PDirectory::GetVolume | ( |  | ) | const

Get the volume name that the directory is in.

This is platform dependent, for example for MS-DOS it is the 11 character volume name for the drive, eg "DOS_DISK", and for Macintosh it is the disks volume name eg "Untitled". For a unix platform it is the device name for the file system eg "/dev/sda1".

Returns
  string for the directory volume.

## GetVolumeSpace()

PBoolean PDirectory::GetVolumeSpace | ( | PInt64 & | total,
|  | PInt64 & | free,
|  | DWORD & | clusterSize
| ) |  | const

Determine the total number of bytes and number of bytes free on the volume that this directory is contained on.

Note that the free space will be the physical limit and if user quotas are in force by the operating system, the use may not actually be able to use all of these bytes.

Returns
  true if the information could be determined.

Parameters

  total | Total number of bytes available on volume
  free | Number of bytes unused on the volume
  clusterSize | "Quantisation factor" in bytes for files on volume

## IsRoot()

PBoolean PDirectory::IsRoot | ( |  | ) | const

Determine if the directory is the root directory of a volume.

Returns
  true if the object is a root directory.

## IsSeparator()

static PINLINE PBoolean PDirectory::IsSeparator | ( | char | ch | ) |

static

Determine if the character `ch` is a directory path separator.

Returns
  true if may be used to separate directories in a path.

Parameters

  ch | Character to check as being a separator.

## IsSubDir()

virtual PBoolean PDirectory::IsSubDir | ( |  | ) | const

virtual

Determine if the directory entry currently being scanned is itself another directory entry.

Note that the directory scan will {not} return the "." and ".." entries that some platforms support.

Returns
  true if entry is a subdirectory.

## Next()

PBoolean PDirectory::Next | ( |  | ) |

Move to the next file in the directory scan.

Only files that are of a type that is specified in the mask passed to the `Open()` or `Restart()` functions will be returned.

Note that the directory scan will {not} return the "." and ".." entries that some platforms support.

Returns
  true if there is another valid file in the directory.

Referenced by PLoadPluginDirectory().

## Open()

virtual PBoolean PDirectory::Open | ( | int | scanMask = `PFileInfo::AllFiles` | ) |

virtual

Open the directory for scanning its list of files.

Once opened the `GetEntryName()` function may be used to get the current directory entry and the `Next()` function used to move to the next directory entry.

Only files that are of a type that is specified in the mask will be returned.

Note that the directory scan will {not} return the "." and ".." entries that some platforms support.

Returns
  true if directory was successfully opened, and there was at least one file in it of the specified types.

Parameters

  scanMask | Mask of files to provide.

Referenced by PLoadPluginDirectory().

## operator=() [1/2]

PDirectory& PDirectory::operator= | ( | const PString & | pathname | ) |

Set the directory to the specified path.

Parameters

  pathname | Directory path name for new object.

## operator=() [2/2]

PDirectory& PDirectory::operator= | ( | const char * | cpathname | ) |

Set the directory to the specified path.

Parameters

  cpathname | Directory path name for new object.

## Remove() [1/2]

PBoolean PDirectory::Remove | ( |  | ) |

Delete the directory.

Returns
  true if directory was deleted.

## Remove() [2/2]

static PBoolean PDirectory::Remove | ( | const PString & | path | ) |

static

Delete the specified directory.

Returns
  true if directory was deleted.

Parameters

  path | Directory file path.

## Restart()

virtual PBoolean PDirectory::Restart | ( | int | scanMask = `PFileInfo::AllFiles` | ) |

virtual

Restart file list scan from the beginning of directory.

This is similar to the `Open()` command but does not require that the directory be closed (using `Close()`) first.

Only files that are of a type that is specified in the mask will be returned.

Note that the directory scan will {not} return the "." and ".." entries that some platforms support.

Returns
  true if directory was successfully opened, and there was at least one file in it of the specified types.

Parameters

  scanMask | Mask of files to provide.

## Member Data Documentation

## directory

DIR* PDirectory::directory

protected

## entryBuffer

struct dirent* PDirectory::entryBuffer

protected

## entryInfo

PFileInfo* PDirectory::entryInfo

protected

## scanMask

int PDirectory::scanMask

protected

Mask of file types that the directory scan will return.

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

- pdirect.h