3ds Max C++ API Reference
|
Path type - adds path-operation richness over symbol strings. More...
#include <Path.h>
Public Member Functions | |
UtilExport | Path () |
Default constructor - creates an empty path. More... | |
UtilExport | Path (const MSTR &pathString) |
Construct a path from a path-filename string. More... | |
UtilExport | Path (const MCHAR *pathString) |
Construct from a null-terminated path-filename MCHAR array. More... | |
UtilExport | Path (const Path &other) |
Copy construct a Path from another. More... | |
UtilExport | ~Path () |
Destructor. More... | |
UtilExport Path & | SetPath (const Path &other) |
Set this Path from another. More... | |
UtilExport Path & | SetPath (const MCHAR *pathString) |
Set this Path's internal string from a null terminated character string. More... | |
UtilExport Path & | SetPath (const MSTR &pathString) |
Set this Path from a MSTR. More... | |
UtilExport Path & | operator= (const Path &other) |
Assignment operator. More... | |
UtilExport Path & | operator= (const MCHAR *pathString) |
Assignment operator taking a null terminated character string. More... | |
UtilExport Path & | operator= (const MSTR &pathString) |
Assignment operator. More... | |
UtilExport bool | IsAbsolute () const |
Get whether this is an absolutely specified path. More... | |
UtilExport bool | IsEmpty () const |
Get whether this is an empty path. More... | |
UtilExport bool | IsLegal () const |
Query whether this path doesn't have any illegal characters according to the Windows platform rules. More... | |
UtilExport bool | IsRoot () const |
Check if this path is just a root. More... | |
UtilExport bool | IsUnc () const |
Query whether this path is a UNC path. More... | |
UtilExport bool | IsUncShare () const |
Query whether this path fits the pattern for a UNC share. More... | |
UtilExport bool | IsRootedAtBackslash () const |
Query whether this path is rooted at backslash, that is at the current drive with no drive letter. More... | |
UtilExport bool | IsRootedAtDriveLetter () const |
Query whether this path is rooted at a drive letter. More... | |
UtilExport bool | HasUnresolvedSymbols () const |
Query whether unresolved symbols remain in this string. More... | |
UtilExport bool | StartsWithUpDirectory () const |
Query with this path, when normalized, starts with "..". More... | |
UtilExport bool | IsEqual (const Path &other) const |
Query whether this and the passed-in path are exactly the same. More... | |
UtilExport bool | operator== (const Path &other) const |
Query whether this and the passed-in path are exactly the same. More... | |
UtilExport bool | ResolvesEquivalent (const Path &other) const |
Query whether this and the passed-in path currently point to the same location. More... | |
UtilExport bool | HasTrailingBackslash () const |
Query whether this path has a trailing backslash. More... | |
UtilExport Path & | AddTrailingBackslash () |
Add a backslash to the end of this path if there isn't one already. More... | |
UtilExport Path & | RemoveTrailingBackslash () |
Remove any trailing backslash from this path. More... | |
UtilExport Path & | Prepend (const Path &newParent) |
Add a new parent path to the start of this path. More... | |
UtilExport Path & | Append (const Path &relativeChild) |
Add a new child path at the end of this path. More... | |
UtilExport Path & | StripToTopParent () |
Strip all but the topmost parent from this path. More... | |
UtilExport Path & | RemoveTopParent () |
Remove the topmost parent from this path. More... | |
UtilExport Path & | StripToLeaf () |
Strip all but the very last child from this path. More... | |
UtilExport Path & | RemoveLeaf () |
Remove the very last child from this path. More... | |
UtilExport Path & | ResolveSymbols () |
Resolve out any symbols in the path string. More... | |
UtilExport Path & | Normalize () |
Transform this path into its normal form. More... | |
UtilExport Path & | ConvertToLowerCase () |
Convert all the characters in this path to lower case. More... | |
UtilExport Path & | ConvertToRelativeTo (const Path &newBase) |
Convert this absolute Path so that it points to the same location, but relative to the new base path. More... | |
UtilExport Path & | ConvertToUNC () |
Convert this mapped drive Path to a UNC path with a host and share name. More... | |
UtilExport Path & | ConvertToAbsolute () |
Convert this relative path to absolute rooted at the current 3ds Max Project Folder. More... | |
UtilExport const Path & | GetResolvedAbsolutePath () const |
Get the fully-resolved, lower case, path converted to absolute rooted at the current 3ds Max Project Folder. More... | |
UtilExport Path & | ConvertToRelativeToProjectFolder () |
Converts an absolute path into a path that is relative to the current Project Folder. More... | |
UtilExport bool | Exists () |
Queries whether the file or directory exists. More... | |
UtilExport bool | IsRootedToFolder (const Path &folder) const |
Queries whether the file or directory is rooted to the specified folder. More... | |
UtilExport MSTR | GetString () const |
Get the current string representation of this path. More... | |
UtilExport const MCHAR * | GetCStr () const |
Get the internal c-string formatted data representation for this path. More... | |
UtilExport bool | SaveBaseFile () const |
Creates base file to support incremental upload of Autodesk 360 files if applicable. More... | |
PathImpl & | GetImpl () |
Not exported outside the DLL - for use by PathImpl only. More... | |
const PathImpl & | GetImpl () const |
Not exported outside the DLL - for use by PathImpl only. More... | |
Additional Inherited Members | |
![]() | |
static UtilExport void * | operator new (size_t size) |
Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e) |
Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new (size_t size, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, int block_type, const char *filename, int line) |
New operator used to allocate arrays of objects. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void * | operator new[] (size_t size, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More... | |
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, unsigned long flags) |
New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More... | |
static UtilExport void | operator delete (void *ptr) |
Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete (void *ptr, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e) |
Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, int block_type, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More... | |
static UtilExport void | operator delete[] (void *ptr, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags) |
Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More... | |
static UtilExport void * | operator new (size_t size, void *placement_ptr) |
Placement new operator. More... | |
static UtilExport void | operator delete (void *ptr, void *placement_ptr) |
Placement delete operator. More... | |
static UtilExport void * | aligned_malloc (size_t size, size_t alignment) |
Allocates memory on a specified alignment boundary. More... | |
static UtilExport void * | aligned_realloc (void *ptr, size_t size, size_t alignment) |
Reallocates memory on a specified alignment boundary. More... | |
static UtilExport void | aligned_free (void *ptr) |
Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More... | |
Path type - adds path-operation richness over symbol strings.
The Path interface provides operations for path composition (Path::Append and Path::Prepend ) and decomposition (Path::StripToTopParent, Path::StripToLeaf, Path::RemoveTopParent, Path::RemoveLeaf), query methods for determining information about a Path, such as whether it's absolute, relative, a root or a UNC, and finally, quick conversions from relative to absolute or absolute to relative.
Note paths are automatically kept in a standard form, where:
Normalization is a separate, explicit method that must be called by the client. Normalization removes null directories \\.\\
and adds in any missing backslash after the drive letter. Wherever possible, normalization will resolve out any ".." path components so: "r:\\dirA\\dirB\\..\\dirC" becomes "r:\\dirA\\dirC." If these hit the root, they just get stripped off, so "r:\\.." normalizes to "r:\\" If the path is relative, and there are more ".."s than preceding directories, the extra sets are kept at the start of the path: "b\\..\\..\\c" becomes "..\\c" Any trailing backslash is kept on the path for compatibility with many win32 API functions. If a uniform trailing-backslash format is desired, for example, for display in the UI, it is up to client-level code to implement this policy. Unresolved symbols are left intact during normalization. Resolving the symbols in a string normalizes automatically.
To reiterate, normalization as performed by the Normalize() method is different from the basic standard form maintained by all members of Path. The client must call Normalize() explicitly (or ResolveSymbols() which is the only method that calls Normalize() automatically). The reason that these are kept separate is to keep from radically modifying a path in a way that may be surprising to a user. If the user wishes to construct a path with many '..\'s in it, the user will expect to see this result. Normalize() may then be called subsequently when it is deemed appropriate.
To illustrate the difference:
UtilExport Path | ( | ) |
Default constructor - creates an empty path.
UtilExport Path | ( | const MSTR & | pathString | ) |
Construct a path from a path-filename string.
pathString | path & filename as a string from which to construct a path object. |
UtilExport Path | ( | const MCHAR * | pathString | ) |
Construct from a null-terminated path-filename MCHAR array.
pathString | path & filename (must be null-terminated). |
UtilExport Path | ( | const Path & | other | ) |
Copy construct a Path from another.
This performs a deep copy. Subsequent operations on this path will not affect the copied path and vice versa.
other | The path to copy. |
UtilExport ~Path | ( | ) |
Destructor.
UtilExport Path& SetPath | ( | const Path & | other | ) |
UtilExport Path& SetPath | ( | const MCHAR * | pathString | ) |
UtilExport Path& SetPath | ( | const MSTR & | pathString | ) |
UtilExport Path& operator= | ( | const Path & | other | ) |
Assignment operator.
other | - path to copy |
UtilExport Path& operator= | ( | const MCHAR * | pathString | ) |
Assignment operator taking a null terminated character string.
pathString | null-terminated character string to copy into this path. |
UtilExport Path& operator= | ( | const MSTR & | pathString | ) |
Assignment operator.
pathString | MSTR to copy into this path. |
UtilExport bool IsAbsolute | ( | ) | const |
Get whether this is an absolutely specified path.
An absolute path is rooted from a starting backslash (\), drive letter or UNC hostname.
UtilExport bool IsEmpty | ( | ) | const |
Get whether this is an empty path.
An empty path has a backing string representation of "".
UtilExport bool IsLegal | ( | ) | const |
Query whether this path doesn't have any illegal characters according to the Windows platform rules.
Illegal characters are ':' for any character but the second and any occurrence of * ? " < > or |.
UtilExport bool IsRoot | ( | ) | const |
Check if this path is just a root.
Possible roots are:
Note that all roots are absolute paths, but not all absolute paths are roots.
The host or drive letter does not have to exist. This path just has to fit the pattern.
UtilExport bool IsUnc | ( | ) | const |
Query whether this path is a UNC path.
A UNC path fits "\\\\host" or "\\\\host\\share" or "\\\\host\\share\\subdirectory\\". The host doesn't necessarily have to exist.
UtilExport bool IsUncShare | ( | ) | const |
Query whether this path fits the pattern for a UNC share.
The UNC share pattern is \\host\share.
UtilExport bool IsRootedAtBackslash | ( | ) | const |
Query whether this path is rooted at backslash, that is at the current drive with no drive letter.
e.g. "\\abc\\def" is rooted at backslash.
UtilExport bool IsRootedAtDriveLetter | ( | ) | const |
Query whether this path is rooted at a drive letter.
UtilExport bool HasUnresolvedSymbols | ( | ) | const |
Query whether unresolved symbols remain in this string.
UtilExport bool StartsWithUpDirectory | ( | ) | const |
Query with this path, when normalized, starts with "..".
UtilExport bool IsEqual | ( | const Path & | other | ) | const |
Query whether this and the passed-in path are exactly the same.
This does not perform any path resolution to try to determine if the paths point to the same file. To be equal, the two paths must have exactly the same current representation.
other | a path to check for equality with this one. |
UtilExport bool operator== | ( | const Path & | other | ) | const |
Query whether this and the passed-in path are exactly the same.
This is a convenience operator overload. It calls IsEqual() under the hood.
other | a path to check for equality with this one. |
UtilExport bool ResolvesEquivalent | ( | const Path & | other | ) | const |
Query whether this and the passed-in path currently point to the same location.
This may not remain true (or false) if the paths contain symbols that may resolve differently later on.
other | a path to check for equivalence with this one |
UtilExport bool HasTrailingBackslash | ( | ) | const |
Query whether this path has a trailing backslash.
UtilExport Path& AddTrailingBackslash | ( | ) |
Add a backslash to the end of this path if there isn't one already.
UtilExport Path& RemoveTrailingBackslash | ( | ) |
Remove any trailing backslash from this path.
Does nothing if there is no trailing backslash.
UtilExport Path& Prepend | ( | const Path & | newParent | ) |
Add a new parent path to the start of this path.
While the usual cleaning up is done, Normalization is not performed. No checking is performed to verify that the resulting path will be legal. Generally, this Path should be relative while the new parent path may be absolute or relative.
Examples:
Path
("a\\b\\c").Prepend(Path("e\\f\\g")) produces Path
("e\\f\\g\\a\\b\\c") Path
("c:\\").Prepend(Path("e\\f\\g")) produces Path
("e\\f\\g\\c:") Path
("a\\b\\c").Prepend(Path("c:\\")) produces Path
("c:\\a\\b\\c") Path
("").Prepend(Path("e\\f\\g")) produces Path
("e\\f\\g") Path
("..\\d").Prepend(Path("e\\f\\g")) produces Path
("e\\f\\g\\..\\d") and normalizes to Path
("e\\f\\d") after a call to Normalize()
To convert a relative path to an absolute path with an arbitrary base, simply Prepend that base to this relative path.
newParent | The new parent path to place at the start of this path. |
UtilExport Path& Append | ( | const Path & | relativeChild | ) |
Add a new child path at the end of this path.
While the usual cleaning up is done, Normalization is not performed. No checking is performed to verify that the resulting path will be legal. Generally, the new child should be relative should be relative, while this base path may be absolute or relative.
Examples:
Path
("a\\b\\c").Append(Path("e\\f\\g")) produces Path
("a\\b\\c\\e\\f\\g") Path
("c:\\").Append(Path("e\\f\\g")) produces Path
("c:\\e\\f\\g") Path
("a\\b\\c").Append(Path("c:\\")) produces Path
("a\\b\\c\\c:") Path
("").Append(Path("e\\f\\g")) produces Path
("e\\f\\g") Path
("a\\b\\c").Append(Path("..\\d")) produces Path
("a\\b\\c\\..\\d") and normalizes to Path
("a\\b\\d") after a call to Normalize()
relativeChild | the new relative child component for this path. |
UtilExport Path& StripToTopParent | ( | ) |
Strip all but the topmost parent from this path.
Examples:
Path
("a\\b\\c").StripToTopParent() produces Path
("a") Path
("c:\\dir").StripToTopParent() produces Path
("c:\\") Path
("a").StripToTopParent() produces Path
("a")UtilExport Path& RemoveTopParent | ( | ) |
Remove the topmost parent from this path.
Examples:
Path
("a\\b\\c").RemoveTopParent() produces Path
("b\\c") Path
("c:\\dir").RemoveTopParent() produces Path
("dir") Path
("a").RemoveTopParent() produces Path
("")UtilExport Path& StripToLeaf | ( | ) |
Strip all but the very last child from this path.
Examples:
Path
("a\\b\\c").StripToLeaf() produces Path
("c") Path
("c:\\dir").StripToLeaf() produces Path
("dir") Path
("a").StripToLeaf() produces Path
("a")UtilExport Path& RemoveLeaf | ( | ) |
Remove the very last child from this path.
Examples:
Path
("a\\b\\c").RemoveLeaf() produces Path
("a\\b") Path
("c:\\dir").RemoveLeaf() produces Path
("c:\\") Path
("a").RemoveLeaf() produces Path
("")UtilExport Path& ResolveSymbols | ( | ) |
UtilExport Path& Normalize | ( | ) |
Transform this path into its normal form.
This will clean up pieces not following the backslash rules outlined in the class documentation, and will convert ".."s as much as possible. "r:\\dirA\\dirB\\..\\dirC" becomes "r:\\dirA\\dirC." If these hit the root, they just get stripped off, so "r:\\.." normalizes to "r:\\" If the path is relative, and there are more ".."s than preceding directories, the extra sets are kept at the start of the path: "b\\..\\..\\c" becomes "..\\c"
Any symbols in the path will be maintained since a symbol may resolve out to more than one directory.
UtilExport Path& ConvertToLowerCase | ( | ) |
Convert all the characters in this path to lower case.
UtilExport Path& ConvertToRelativeTo | ( | const Path & | newBase | ) |
Convert this absolute Path so that it points to the same location, but relative to the new base path.
The following attempted conversions are invalid and will leave the path unchanged:
Example: Path
("c:\\a\\b\\c").ConvertToRelativeTo(Path("c:\\a\\b\\d") produces Path
("..\\c")
newBase | absolute base path from which this Path must later be rooted to point to its current location again. |
UtilExport Path& ConvertToUNC | ( | ) |
UtilExport Path& ConvertToAbsolute | ( | ) |
Convert this relative path to absolute rooted at the current 3ds Max Project Folder.
This will automatically resolve any symbols and normalize this path. If this Path already resolves to an absolute Path, it will ignore the current working directory. This does not resolve the path using the 3ds Max file search mechanism.
If conversion to an arbitrarily-rooted absolute path is desired, Prepend
should be used instead.
UtilExport const Path& GetResolvedAbsolutePath | ( | ) | const |
Get the fully-resolved, lower case, path converted to absolute rooted at the current 3ds Max Project Folder.
This is a performance-oriented convenience method for clients that wish to hold on to the original, unresolved, relative path yet often need to access the absolute path.
UtilExport Path& ConvertToRelativeToProjectFolder | ( | ) |
Converts an absolute path into a path that is relative to the current Project Folder.
Converts an absolute path into a path that is relative to the current Project Folder. If the path cannot be made relative (if it is rooted on a different drive, for instance), then it is left untouched. If the path is already relative, it is also left untouched.
UtilExport bool Exists | ( | ) |
Queries whether the file or directory exists.
This works on both files and directories.
UtilExport bool IsRootedToFolder | ( | const Path & | folder | ) | const |
Queries whether the file or directory is rooted to the specified folder.
This works on both files and directories.
UtilExport MSTR GetString | ( | ) | const |
Get the current string representation of this path.
Note that this does not perform any symbol resolution or normalization.
UtilExport const MCHAR* GetCStr | ( | ) | const |
Get the internal c-string formatted data representation for this path.
Note that this c-string is not guaranteed to be consistent after any modifications are made to the Path object. If the data is needed persistently, consider either copying the contents of this pointer, or calling GetString() instead.
UtilExport bool SaveBaseFile | ( | ) | const |
Creates base file to support incremental upload of Autodesk 360 files if applicable.
This function should be called before a file which is in sync is overwritten with a new version (typically during save operation). This is necessary to support incremental upload of the file. It must be called every time the file is overwritten (i.e. on every save). This function creates a base file using the current version which will be used by the sync engine to upload only the changes. If the file specified by this path is not an Autodesk 360 sync'ed file, no action occurs as a result of this call.
PathImpl& GetImpl | ( | ) |
Not exported outside the DLL - for use by PathImpl only.
const PathImpl& GetImpl | ( | ) | const |
Not exported outside the DLL - for use by PathImpl only.
Same as the other version, but this one's for const-context.