The Path object represents a file or folder path. Many objects have properties that return a Path - for example, Tab.path returns the current folder in a tab as a Path object. You can create a new Path object from a string (or another Path) using the DOpus.FSUtil.NewPath method.
Property Name |
Return Type |
Description |
---|---|---|
<default value> |
string |
Returns the full path as a string. |
components |
int |
Returns the number of components in the path. |
disks |
Vector:int |
Returns a Vector of ints representing the physical disk drive or drives that this path resides on. |
drive |
int |
Returns the drive number the path refers to (1=A, 2=B, etc.) or 0 if the path does not specify a drive. You can also change the drive letter of the path (while leaving the following path components alone) by modifying this value. |
ext |
string |
Returns the filename extension of the path (the sub-string
extending from the last . in the final
component to the end of the string). This method does not check if the
path actually refers to a file. |
ext_m |
string |
Returns the filename extension of the path, taking multi-part
extensions into account. For example, ext might return
".rar" whereas ext_m would return
".part1.rar". |
filepart |
string |
Returns the filename part of the path (the last component). |
longpath |
object:Path |
If this object represents a short pathname, this property returns the "long" equivalent. |
pathpart |
string |
Returns the path minus the last component. |
shortpath |
object:Path |
If this object represents a long pathname, this property returns the "short" equivalent, if it has one. Note that short paths are disabled by default in Windows 10. |
stem |
string |
Returns the filename stem of the path (i.e. filepart minus ext). |
stem_m |
string |
Returns the filename stem taking multi-part extensions into account. For example, stem might return "pictures.part1" whereas stem_m would return "pictures". |
test_parent |
bool |
Returns True if a call to the Parent method would succeed. |
test_root |
bool |
Returns True if a call to the Root method would succeed. |
Method Name |
Arguments |
Return Type |
Description |
---|---|---|---|
Add |
<string:name> |
none |
Adds the specified name to the path (it will become the last component). As well as a string, you can pass a Vector of strings and all items in the vector will be added to the path. |
Parent |
none |
bool |
Removes the last component of the path. Returns False if the path does not have a valid parent. |
ReplaceStart |
<string:old> |
bool |
Compares the beginning of the path with the "old" string, and if it matches replaces it with the "new" string. The match is performed at the path component level - for example, an "old" string of "C:\Foo" would match the path "C:\Foo\Bar" but not "C:\FooBar". If the optional "wholepath" argument is set to True then the whole path must match rather than just its beginning. Returns True if the string matched the path or False otherwise. |
Root |
none |
bool |
Strips off all but the first component of the path. Returns False if the path is already at the root. |
Set |
<string:path> |
none |
Sets the path represented by the Path object to the specified string. You can also set one Path object to the value of another. If you pass a Vector of strings the path will be built from the items in the vector. |
Split |
<int:first> |
Vector:string |
Returns a Vector of strings representing the components of the path. For example, if the path is C:\Foo\Bar, the vector will contain three items - "C:\", "Foo" and "Bar". By default all components of the path are returned, but you can optionally provide the index of the first component and also the number of components to return. |