Difference between revisions of "CXFilePath"
From cxwiki
Line 63: | Line 63: | ||
| | ||
+ | <div class="mw-parser-output"> | ||
= Helper Methods = | = Helper Methods = | ||
+ | |||
+ | // convert to lowercase; useful for filename matching on case-insensitive systems | ||
+ | |||
+ | void ToLower(void); | ||
| | ||
− | + | ||
+ | static String GetSafeFilename(const char* __nonnull filename); | ||
+ | |||
+ | | ||
+ | |||
+ | static QUAL ResolvePathRelativeTo(const QUAL& relativeOrAbsolutePath, const QUAL& basePathForRelative); | ||
+ | |||
+ | static QUAL GetPathRelativeTo(const QUAL& absolutePath, QUAL basePathForRelative); | ||
+ | |||
+ | static bool IsPathRelativeTo(const QUAL& absolutePath, const QUAL& basePathForRelative); | ||
+ | |||
+ | | ||
+ | |||
+ | CXString AsFileURIString(void) const; | ||
+ | </div> |
Revision as of 19:39, 25 February 2018
Contents
Native Encodings
Windows
Posix
Construction
Various constructors are available to allow a CXFilePath to be build from a C String, string classes, etc.
//
CXFilePath(void);
//
CXFilePath(const char* __nullable path);
CXFilePath(const CXString& path);
CXFilePath(const CXStringEdit& path);
template <class OP> inline CXFilePath(const CXFilePathBase<OP>& other);
Nullness
CXFilePath does not distinguish between null and empty states. An empty filepath cannot be used to reference a file (although it can be appended as a relative filepath, to no effect) and so it is typically treated as a sentinel for a null / invalid / unset value.
// Returns true if this CXFilePath object has a non-zero length.
operator bool(void) const;
// Returns true if this CXFilePath is empty.
bool operator !(void) const;
Path Operations
// Returns the filename portion of this path.
CXString GetFilename(void) const;
// Removes and returns the leftmost path element (root).
CXString StripLeftElement(bool bShouldStripFilenameElement = true);
// Remove and return the rightmost path element (filename).
CXString StripRightElement(void);
// Returns the path minus its rightmost path element.
CXString GetParentPath(void) const;
// Returns true if this object represents an absolute path.
// TBD.
bool IsAbsolutePath(void) const;
// Returns true if this object represents the filesystem root.
// TBD.
bool IsRoot(void) const;
// Returns true if this object contains a file name but no path separators.
bool IsFilenameOnly(void) const;
// Attempt to resolve any './' and '../' references, symlinks, etc.
// TBD.
bool Resolve(void);
Helper Methods
// convert to lowercase; useful for filename matching on case-insensitive systems
void ToLower(void);
static String GetSafeFilename(const char* __nonnull filename);
static QUAL ResolvePathRelativeTo(const QUAL& relativeOrAbsolutePath, const QUAL& basePathForRelative);
static QUAL GetPathRelativeTo(const QUAL& absolutePath, QUAL basePathForRelative);
static bool IsPathRelativeTo(const QUAL& absolutePath, const QUAL& basePathForRelative);
CXString AsFileURIString(void) const;