#include <Path.h>
Classes | |
struct | PathIterable |
Public Types | |
using | string_view_type = AZStd::string_view |
using | value_type = char |
using | const_iterator = PathIterator< const PathView > |
using | iterator = const_iterator |
Public Member Functions | |
constexpr | PathView (const PathView &other)=default |
constexpr | PathView (AZStd::string_view pathView) noexcept |
constexpr | PathView (AZStd::string_view pathView, const char preferredSeparator) noexcept |
constexpr | PathView (const value_type *pathString) noexcept |
constexpr | PathView (const value_type *pathString, const char preferredSeparator) noexcept |
constexpr | PathView (const char preferredSeparator) noexcept |
constexpr PathView & | operator= (const PathView &other)=default |
constexpr PathView & | operator= (AZStd::string_view pathView) noexcept |
constexpr PathView & | operator= (const value_type *pathView) noexcept |
constexpr void | swap (PathView &rhs) noexcept |
constexpr const AZStd::string_view & | Native () const noexcept |
Returns string_view stored within the PathView. | |
constexpr AZStd::string_view & | Native () noexcept |
constexpr | operator AZStd::string_view () const noexcept |
Conversion operator to retrieve string_view stored within the PathView. | |
constexpr int | Compare (const PathView &other) const noexcept |
constexpr int | Compare (AZStd::string_view pathString) const noexcept |
constexpr int | Compare (const value_type *pathString) const noexcept |
AZStd::string | String () const |
constexpr AZStd::fixed_string< MaxPathLength > | FixedMaxPathString () const noexcept |
constexpr AZStd::fixed_string< MaxPathLength > | FixedMaxPathStringAsPosix () const noexcept |
AZStd::string | StringAsPosix () const |
AZStd::fixed_string< MaxPathLength > | AsUri () const noexcept |
AZStd::string | StringAsUri () const |
AZStd::fixed_string< MaxPathLength > | FixedMaxPathStringAsUri () const noexcept |
constexpr PathView | RootName () const |
constexpr PathView | RootDirectory () const |
constexpr PathView | RootPath () const |
constexpr PathView | RelativePath () const |
constexpr PathView | ParentPath () const |
constexpr PathView | Filename () const |
constexpr PathView | Stem () const |
constexpr PathView | Extension () const |
constexpr bool | empty () const noexcept |
Checks if the contained string type element is empty. | |
constexpr bool | HasRootName () const |
constexpr bool | HasRootDirectory () const |
Checks if the path has a root directory. | |
constexpr bool | HasRootPath () const |
constexpr bool | HasRelativePath () const |
constexpr bool | HasParentPath () const |
checks whether the path has a parent path that is empty | |
constexpr bool | HasFilename () const |
Checks whether the filename is empty. | |
constexpr bool | HasStem () const |
Checks whether the stem of the filename is empty <stem>[.<ext>]. | |
constexpr bool | HasExtension () const |
Checks whether the extension of the filename is empty <stem>[.<ext>]. | |
constexpr bool | IsAbsolute () const |
constexpr bool | IsRelative () const |
Check whether the path is not absolute. | |
constexpr bool | IsRelativeTo (const PathView &base) const |
Check whether the path is relative to the base path. | |
constexpr const char | PreferredSeparator () const noexcept |
Returns the preferred separator for this instance. | |
constexpr FixedMaxPath | LexicallyNormal () const |
constexpr FixedMaxPath | LexicallyRelative (const PathView &base) const |
constexpr FixedMaxPath | LexicallyProximate (const PathView &base) const |
Returns the lexically relative path if it is not an empty path, otherwise it returns the current *this path. | |
constexpr bool | Match (AZStd::string_view pathPattern) const |
constexpr const_iterator | begin () const |
constexpr const_iterator | end () const |
Public Attributes | |
friend | const_iterator |
Friends | |
template<typename StringType > | |
class | BasicPath |
struct | AZStd::hash< PathView > |
Implementation of a Path class for providing an abstraction of paths on the file system This class represents paths provides an abstraction for paths on a filesystem Only the syntactic parts of a path are handled. The actual paths stored may represent non-existing paths or paths that are not possible on the current OS/filesystem A path name is made up of the following segments
This is normally only set for paths on Windows OS
if missing and the first-element other than the root-name is a filename, then this represents a relative path
separators. Filenames may identify a file, hard link, symbolic link, or directory
On windows the preferred separator is '\' If this character is repeated it is treated as a single directory separator i.e /usr///////lib is the same as /usr/lib
Paths can be traversed elmeent wise using the begin()/end() functions This views the path in the generic format and iterators over the path in order of root-name -> root-directory -> file name(0 or more times) directory separators are skipped except for the one that represents the root directory A iterated path element is never empty
|
constexprnoexcept |
Constructs a PathView by the storing the supplied string_view The preferred separator is to the OS default path separator
|
constexprnoexcept |
Constructs a PathView by the storing the supplied string_view The preferred separator it set to the parameter
|
constexprnoexcept |
Constructs a PathView by storing the value_type* into a string_view The preferred separator is to the OS default path separator
|
constexprnoexcept |
Constructs a PathView by storing the value_type* into a string_view The preferred separator it set to the parameter
|
noexcept |
Models the Python pathlib as_uri method Percent encodes the path and appends file: to the front
|
constexpr |
Returns an iterator to the beginning of the path that can be used to traverse the path according to the following
|
constexprnoexcept |
Performs a compare of each of the path parts for equivalence Each part of the path is compare using string comparison Ex: Comparing "test/foo" against "test/fop" returns -1; Path separators of the contained path string aren't compared Ex. Comparing "C:/test\foo" against C:
|
constexpr |
Returns an iterator to the end of the path element This iterator can be safely decremented to point to the last valid path element if it is not equal to the begin iterator
|
constexpr |
Returns the extension of the filename (or equivalently, the filename of the path with the stem stripped) windows = ".txt", posix = ".txt" NOTE: If the filename is the special "." or ".." path then their is no extension in that case
|
constexpr |
Returns the filename of the path windows = "name.txt", posix = "name.txt"
|
constexprnoexcept |
extension: fixed string types with MaxPathLength capacity Returns a new instance of an AZStd::fixed_string with capacity of MaxPathLength made from the internal string
|
constexprnoexcept |
Replicates the behavior of the Python pathlib as_posix method by replacing the Windows Path Separator with the Posix Path Seperator
|
constexpr |
checks whether the relative part of path is empty (C:\ O3DE\dev) ^ ^ root part relative part
|
constexpr |
Checks if the path has a root name For posix paths this is always empty For windows paths this is the part of the path before the either the root directory or relative path part
|
constexpr |
Checks whether the entire root path portion of the path is empty The root portion of the path is made up of root_name() / root_directory()
|
constexpr |
Checks whether the contained path represents an absolute path If a path starts with a '/', "<drive letter>:\", "\<network_name>", "\\?\", "\??" or "\\.\"
|
constexpr |
Normalizes a path in a purely lexical manner.
The preceding directory is also removed
unless the path begins with two path separators
|
constexpr |
Make the path relative to the supplied base PathView, by using the following rules.
(Path can't relative if the root_names are different i.e C: vs F:)
(A relative path can't be formed out of when one path is absolute and the other isn't)
(Again if one path contains a root directory and the other doesn't a relative path can't be formed
return a default constructed path (This is the occasion of having a "path" such as "foo/bar/C:/foo/bar". Such a path cannot be made relative
auto [a, b] = AZStd::mismatch(begin(), end(), base.begin(), base.end())
the number of ".." elements. N is less than 0 then return a default constructed path (This is the case of all the parent directories of base being consumed by the "..". Such as a path of "foo/../bar/../..")
(This is the case of a making "a/b/c" relative to a path such as "a/b/c/d/.."
N applications of the Path append operator on "..", followed by an application of the path append operator for each element in the range of a[a, end()] (Example of this case is making "/a/d" relative to "/a/b/c". The mismatch happens on "d" for *this and b for base the number of path elements remaining from "b" to "base.end" is 2("b", "c"). Therefore two applications of ".." is formed So the path at this point is "../..", then the remaining elements in the mismatched range for *this is then append There is only 1 element in the range of [a, end()] and that is "d", so the final path becomes "../../d"
|
constexpr |
Returns true if given pattern matches against the path using glob-style pattern expansion The Match algorithm works as follows
If the pattern is relative, then the path can be either absolute or relative and matching is done from the end Ex. AZ::IO::PathView("a/b.ext").Match("*.ext") -> True AZ::IO::PathView("a/b/c.ext").Match("b/*.ext") -> True AZ::IO::PathView("a/b/c.ext").Match("a/*.ext") -> False
is done from the end Ex. AZ::IO::PathView("/a.ext").Match("/*.ext") -> True AZ::IO::PathView("a/b.ext").Match("/*.ext") -> False
Ex. AZ::IO::PathView("a/b/c.ext").Match("a/*‍/c.ext") -> True Ex. AZ::IO::PathView("a/d/e.ext").Match("a/*‍/*.ext") -> True Ex. AZ::IO::PathView("a/g/h.ext").Match("a/*‍/f.ext") -> False
|
constexpr |
Returns the parent directory of filename contained within the path windows = "C:\O3DE\foo\bar", posix = "/O3DE/foo/bar" NOTE: If the path ends with a trailing separator "test/foo/" it is treated as being a path of "test/foo" as if the filename of the path is "foo" and the parent directory is "test"
|
constexpr |
Returns the relative path portion of the path. This contains the path parts after the root path windows = "O3DE\foo\bar\name.txt", posix = "O3DE/foo/bar/name.txt"
|
constexpr |
Returns the root directory part of the path if it has one. This is the root directory separator windows = "\", posix = "/"
|
constexpr |
Given a windows path of "C:\O3DE\foo\bar\name.txt" and a posix path of "/O3DE/foo/bar/name.txt" The following functions return the following Returns the root name part of the path. if it has one. This is the part of the path before the '/' root directory part windows = "C:", posix = ""
|
constexpr |
Returns the full root path portion of the path made as if it joined the root_name() and root_directory() windows = "C:\", posix = "/"
|
constexpr |
Returns the filename of the path stripped of it's extension windows = "name", posix = "name" NOTE: If the filename starts with a "." it is treated as part of the stem i.e "home/user/.vimrc"; The stem porttion is ".vimrc" in this case
AZStd::string AZ::IO::PathView::String | ( | ) | const |
The string and wstring functions cannot be constexpr until AZStd::basic_string is made constexpr. This cannot occur until C++20 as operator new/delete cannot be used within constexpr functions Returns a new instance of an AZStd::string made from the internal string