PTLib
Version 2.18.8
|
This class describes a full description for a file on the particular platform. More...
#include <filepath.h>
Public Member Functions | |
Construction | |
PFilePath () | |
Create an empty file path description. More... | |
PFilePath (const char *cstr) | |
Create a file path description with the specified string. More... | |
PFilePath (const PString &str) | |
Create a file path description with the specified string. More... | |
PFilePath (const PFilePath &path) | |
Create a file path description with the specified file name. More... | |
PFilePath (const char *prefix, const char *dir, const char *suffix=NULL) | |
Create a file path description with a generated temporary name. More... | |
PFilePath & | operator= (const PFilePath &path) |
Change the file path description to the specified file name. More... | |
PFilePath & | operator= (const PString &str) |
Change the file path description to the specified file name. More... | |
PFilePath & | operator= (const char *cstr) |
Change the file path description to the specified file name. More... | |
Path addition functions | |
PFilePath & | operator+= (const PString &str) |
Concatenate a string to the file path, modifiying that path. More... | |
PFilePath & | operator+= (const char *cstr) |
Concatenate a C string to a path, modifiying that path. More... | |
PFilePath & | operator+= (char ch) |
Concatenate a single character to a path. More... | |
Path decoding access functions | |
PFilePathString | GetVolume () const |
Get the drive/volume name component of the full file path description. More... | |
PFilePathString | GetPath () const |
Get the directory path component of the full file path description. More... | |
PFilePathString | GetTitle () const |
Get the title component of the full file path description, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" this would be "FRED". More... | |
PFilePathString | GetType () const |
Get the file type of the file. More... | |
PFilePathString | GetFileName () const |
Get the actual directory entry name component of the full file specification. More... | |
PDirectory | GetDirectory () const |
Get the the directory that the file is contained in. More... | |
void | SetType (const PFilePathString &type) |
Set the type component of the full file path description, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" would become "C:\SRC\PWLIB\FRED.TXT". More... | |
![]() | |
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... | |
bool | MakeMinimumSize (PINDEX newLength=0) |
Set the actual memory block array size to the minimum required to hold the current string contents. More... | |
virtual PINDEX | GetLength () const |
Determine the length of the null terminated string. 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 ®ex, PINDEX offset=0) const |
Locate the position within the string of one of the regular expression. More... | |
PBoolean | FindRegEx (const PRegularExpression ®ex, 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 ®ex) const |
Return true if the entire string matches the regular expression. More... | |
PString & | 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... | |
PString & | Splice (const PString &str, PINDEX pos, PINDEX len=0) |
Splice the string into the current string at the specified position. More... | |
PString & | Splice (const char *cstr, PINDEX pos, PINDEX len=0) |
Splice the string into the current string at the specified position. More... | |
PString & | 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... | |
P_DECLARE_BITWISE_ENUM_EX (SplitOptions, 6,(SplitOnly, SplitTrimBefore, SplitTrimAfter, SplitDefaultToBefore, SplitDefaultToAfter, SplitBeforeNonEmpty, SplitAfterNonEmpty), SplitTrim=SplitTrimBefore|SplitTrimAfter, SplitNonEmpty=SplitBeforeNonEmpty|SplitAfterNonEmpty) | |
Options for PString::Split() function. More... | |
__inline bool | Split (const PString &delimiter, PString &before, PString &after, SplitOptions options=SplitTrim) const |
Split the string into two substrings around delimiter. More... | |
__inline bool | Split (char delimiter, PString &before, PString &after, SplitOptions options) const |
__inline bool | Split (char delimiter, PString &before, PString &after, SplitOptions_Bits options) const |
__inline bool | Split (const char *delimiter, PString &before, PString &after, SplitOptions options) const |
__inline bool | Split (const char *delimiter, PString &before, PString &after, SplitOptions_Bits options) const |
__inline bool | Split (char delimiter, PString &before, PString &after, bool trim) const |
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... | |
PString () | |
Construct an empty string. More... | |
PString (const PString &str) | |
Create a new reference to the specified string. More... | |
PString (const PCharArray &buf) | |
Create a new reference to the specified buffer. More... | |
PString (const PBYTEArray &buf) | |
Create a new string based on the BYTE array. More... | |
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 char *cstr, PINDEX len) | |
Create a string from the wchar_t string 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 (ConversionType type, const char *str,...) | |
PString (ConversionType type, unsigned long value, unsigned param=10) | |
PString (ConversionType type, signed long value, unsigned param=10) | |
PString (ConversionType type, unsigned int value, unsigned param=10) | |
PString (ConversionType type, signed int value, unsigned param=10) | |
PString (ConversionType type, unsigned short value, unsigned param=10) | |
PString (ConversionType type, signed short value, unsigned param=10) | |
PString (ConversionType type, unsigned char value, unsigned param=10) | |
PString (ConversionType type, signed char value, unsigned param=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... | |
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 a PString to another PString 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 PString to a PString, 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... | |
bool | operator*= (const PString &str) const |
Compare two strings using case insensitive comparison. More... | |
bool | operator== (const PString &str) const |
Compare two strings using the PObject::Compare() function. More... | |
bool | operator!= (const PString &str) const |
Compare two strings using the PObject::Compare() function. More... | |
bool | operator< (const PString &str) const |
Compare two strings using the PObject::Compare() function. More... | |
bool | operator> (const PString &str) const |
Compare two strings using the PObject::Compare() function. More... | |
bool | operator<= (const PString &str) const |
Compare two strings using the PObject::Compare() function. More... | |
bool | operator>= (const PString &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... | |
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... | |
template<typename T > | |
__inline T | As (T t=T()) const |
Convert the string to any type that can be converted using a stream. More... | |
long | AsInteger (unsigned base=0) const |
Convert the string to an integer value using the specified number base. More... | |
DWORD | AsUnsigned (unsigned base=0) const |
Convert the string to an integer value using the specified number base. More... | |
int64_t | AsInteger64 (unsigned base=0) const |
Convert the string to an integer value using the specified number base. More... | |
__inline PInt64 | AsInt64 (unsigned base=0) const |
uint64_t | AsUnsigned64 (unsigned base=0) 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... | |
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... | |
PString | FromLiteral (PINDEX &offset) const |
Parse a C literal string format as for PString::ToLiteral(). 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... | |
char * | GetPointerAndSetLength (PINDEX len) |
Get a pointer to the buffer and set the length of the string. More... | |
virtual const char * | GetPointer (PINDEX=0) const |
Get a const pointer to the buffer contents This function overrides the ancestor function that returns a char *. More... | |
__inline std::string::size_type | size () const |
__inline std::string::size_type | length () const |
__inline std::string::size_type | capacity () const |
__inline bool | empty () const |
__inline void | clear () |
__inline const char * | c_str () const |
__inline char * | data () |
__inline void | push_back (char ch) |
__inline PString & | append (std::string::size_type count, char ch) |
__inline PString & | append (const char *s) |
__inline PString & | append (const std::string &s) |
__inline PString & | insert (std::string::size_type index, std::string::size_type count, char ch) |
__inline PString & | insert (std::string::size_type index, const char *s) |
__inline PString & | insert (std::string::size_type index, const std::string &s) |
__inline PString & | erase (std::string::size_type index=0, std::string::size_type count=std::string::npos) |
__inline PString & | replace (std::string::size_type pos, std::string::size_type count, const char *s) |
__inline PString & | replace (std::string::size_type pos, std::string::size_type count, const std::string &s) |
__inline std::string | substr (std::string::size_type pos=0, std::string::size_type count=std::string::npos) const |
__inline std::string::size_type | find (char c, std::string::size_type pos=0) const |
__inline std::string::size_type | find (const char *s, std::string::size_type pos=0) const |
__inline std::string::size_type | find (const std::string &s, std::string::size_type pos=0) const |
__inline std::string::size_type | rfind (char c, std::string::size_type pos=0) const |
__inline std::string::size_type | rfind (const char *s, std::string::size_type pos=0) const |
__inline std::string::size_type | rfind (const std::string &s, std::string::size_type pos=0) const |
__inline std::string::size_type | find_first_of (const char *s, std::string::size_type pos=0) const |
__inline std::string::size_type | find_first_of (const std::string &s, std::string::size_type pos=0) const |
__inline std::string::size_type | find_first_not_of (const char *s, std::string::size_type pos=0) const |
__inline std::string::size_type | find_first_not_of (const std::string &s, std::string::size_type pos=0) const |
![]() | |
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... | |
PCharArray (PContainerReference &reference_) | |
virtual void | PrintOn (ostream &strm) const |
Print the array. More... | |
virtual void | ReadFrom (istream &strm) |
Read the array. More... | |
![]() | |
PBaseArray (PINDEX initialSize=0) | |
Construct a new dynamic array of elements of the specified type. More... | |
PBaseArray (charconst *buffer, PINDEX length, PBoolean dynamic=true) | |
Construct a new dynamic array of elements of the specified type. More... | |
PBoolean | SetAt (PINDEX index, charval) |
Set the specific element in the array. More... | |
char | GetAt (PINDEX index) const |
Get a value from the array. More... | |
void | Attach (const char *buffer, PINDEX bufferSize) |
Attach a pointer to a static block to the base array type. More... | |
char * | GetPointer (PINDEX minSize=0) |
Get a pointer to the internal array and assure that it is of at least the specified size. More... | |
char | operator[] (PINDEX index) const |
Get a value from the array. More... | |
char & | operator[] (PINDEX index) |
Get a reference to value from the array. More... | |
operator charconst * () const | |
Get a pointer to the internal array. More... | |
PBoolean | Concatenate (const PBaseArray &array) |
Concatenate one array to the end of this array. More... | |
![]() | |
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... | |
const void * | GetPointer () const |
PBoolean | Concatenate (const PAbstractArray &array) |
Concatenate one array to the end of this array. More... | |
![]() | |
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... | |
__inline size_t | size () const |
PBoolean | SetMinSize (PINDEX minSize) |
Set the minimum size of container. More... | |
__inline bool | empty () const |
PBoolean | IsUnique () const |
Determine if container is unique reference. More... | |
![]() | |
__inline unsigned | GetTraceContextIdentifier () const |
Get PTRACE context identifier. More... | |
__inline void | SetTraceContextIdentifier (unsigned id) |
__inline void | SetTraceContextIdentifier (const PObject &obj) |
__inline void | SetTraceContextIdentifier (const PObject *obj) |
__inline void | CopyTraceContextIdentifier (PObject &obj) const |
__inline void | CopyTraceContextIdentifier (PObject *obj) const |
virtual | ~PObject () |
__inline const char * | GetClass () const |
__inline bool | IsClass (const char *name) const |
__inline const PObject * | PTraceObjectInstance () const |
template<class CLS > | |
CLS * | CloneAs () const |
As for Clone() but converts to specified type. More... | |
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... | |
Static Public Member Functions | |
static PFilePathString | Canonicalise (const PFilePathString &path, bool isDirectory) |
Miscellaneous functions | |
static bool | IsValid (char c) |
Test if the character is valid in a filename. More... | |
static bool | IsValid (const PString &str) |
Test if all the characters are valid in a filename. More... | |
static PFilePathString | Sanitise (const PString &str, const PString &extra=PString::Empty(), char substitute= '_') |
Sanitise the string to be a legal filename. More... | |
static bool | IsAbsolutePath (const PString &path) |
Test if path is an absolute path or relative path. More... | |
![]() | |
static const PString & | Empty () |
Return an empty string. More... | |
![]() | |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject &to, const PObject *from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject &from) |
static __inline void | CopyTraceContextIdentifier (PObject *to, const PObject *from) |
static __inline const char * | Class () |
static __inline const PObject * | PTraceObjectInstance (const char *) |
static __inline const PObject * | PTraceObjectInstance (const PObject *obj) |
template<typename T > | |
static Comparison | Compare2 (T v1, T v2) |
Compare two types, returning Comparison type. More... | |
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size) |
Internal function caled from CompareObjectMemoryDirect() More... | |
Protected Member Functions | |
virtual void | AssignContents (const PContainer &cont) |
Copy the container contents. More... | |
![]() | |
virtual Comparison | InternalCompare (PINDEX offset, PINDEX length, const char *cstr) const |
virtual int | internal_strcmp (const char *s1, const char *s2) const |
virtual int | internal_strncmp (const char *s1, const char *s2, size_t n) const |
bool | InternalSplit (const PString &delimiter, PString &before, PString &after, SplitOptions_Bits options) const |
PString (int dummy, const PString *str) | |
PString (PContainerReference &reference_, PINDEX len) | |
![]() | |
PBaseArray (PContainerReference &reference_) | |
virtual void | PrintElementOn (ostream &stream, PINDEX index) const |
![]() | |
PBoolean | InternalSetSize (PINDEX newSize, PBoolean force) |
virtual void | PrintElementOn (ostream &stream, PINDEX index) const |
virtual void | ReadElementFrom (istream &stream, PINDEX index) |
PAbstractArray (PContainerReference &reference, PINDEX elementSizeInBytes) | |
![]() | |
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... | |
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... | |
![]() | |
PObject () | |
Constructor for PObject, made protected so cannot ever create one on its own. More... | |
Additional Inherited Members | |
![]() | |
typedef const char * | Initialiser |
enum | ConversionType { Pascal, Basic, Literal, Signed, Unsigned, Decimal, Exponent, ScaleSI, Printf, NumConversionTypes } |
![]() | |
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 } |
Result of the comparison operation performed by the Compare() function. More... | |
![]() | |
PINDEX | m_length |
![]() | |
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... | |
![]() | |
PContainerReference * | reference |
![]() | |
unsigned | m_traceContextIdentifier |
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
.
PFilePath::PFilePath | ( | ) |
Create an empty file path description.
PFilePath::PFilePath | ( | const char * | cstr | ) |
Create a file path description with the specified string.
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 path description is translated into a canonical form which always absolutely references the file.
if cstr is NULL or empty string, then PFilePath is empty.
cstr | Partial C string for file name. |
PFilePath::PFilePath | ( | const PString & | str | ) |
Create a file path description with the specified string.
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 path description is translated into a canonical form which always absolutely references the file.
if str is an empty string, then PFilePath is empty.
str | Partial PString for file name. |
PFilePath::PFilePath | ( | const PFilePath & | path | ) |
Create a file path description with the specified file name.
path | Previous path for file name. |
PFilePath::PFilePath | ( | const char * | prefix, |
const char * | dir, | ||
const char * | suffix = NULL |
||
) |
Create a file path description 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.
prefix | Prefix string for file title. |
dir | Directory in which to place the file. |
suffix | Optional suffix for file |
|
protectedvirtual |
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 PString.
|
static |
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()
.
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".
PFilePathString PFilePath::GetPath | ( | ) | const |
Get the directory path component of the full file path description.
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/".
PFilePathString PFilePath::GetTitle | ( | ) | const |
Get the title component of the full file path description, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" this would be "FRED".
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".
PFilePathString PFilePath::GetVolume | ( | ) | const |
Get the drive/volume name component of the full file path description.
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 ("").
|
static |
Test if path is an absolute path or relative path.
path | path name |
|
static |
Test if the character is valid in a filename.
c | Character to test for validity. |
|
static |
Test if all the characters are valid in a filename.
str | String to test for validity. |
Concatenate a string to the file path, modifiying that path.
str | String to concatenate. |
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";
@return reference to string that was concatenated to.
cstr | C string to concatenate. |
PFilePath& PFilePath::operator+= | ( | char | ch | ) |
Concatenate a single character to a path.
The ch
parameter is typically a literal, eg:
myStr += '!';
@return new string with concatenation of the object and parameter.
Change the file path description to the specified file name.
path | Previous path for file name. |
Change the file path description 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 path is translated into a canonical form which always absolutely references the file.
if str is an empty string, then PFilePath is empty.
str | Partial PString for file name. |
PFilePath& PFilePath::operator= | ( | const char * | cstr | ) |
Change the file path description 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 path is translated into a canonical form which always absolutely references the file.
if cstr is NULL or empty string, then PFilePath is empty.
cstr | Partial "C" string for file name. |
|
static |
Sanitise the string to be a legal filename.
Characters that are not legal, or would consitute a directory separator, are are in the extra
list, are substituted by the substitute
character.
str | String to sanitise |
extra | Extra characters to substitute |
substitute | Character to substitiute |
void PFilePath::SetType | ( | const PFilePathString & | type | ) |
Set the type component of the full file path description, eg for the DOS file "C:\SRC\PWLIB\FRED.DAT" would become "C:\SRC\PWLIB\FRED.TXT".
type | New type of the file. |