Path¶
Represents a path. Contains suffixes that can be helpful when using and manipulating paths. You can use path() to create new instances.
Instances of this structure can be passed as arguments instead of ordinary, string paths, for example:
copypath("../file", path()).
- structure Path¶
Suffix
Type
Description
Volume this path belongs to
List of this path’s segments
Number of segments in this path
Name of file or directory this path points to
True if path contains an extension
This path’s extension
Root path of this path’s volume
Parent path
Returns a new path with its name (last segment) changed
Returns a new path with extension changed
True if path is the parent of this path
Returns a new path created by adding further elements to this one
- Path:SEGMENTS¶
-
List of segments this path contains. Segments are parts of the path separated by /. For example path 0:/directory/subdirectory/script.ks contains the following segments: directory, subdirectory and script.ks.
- Path:NAME¶
- Type
- Access
Get only
Name of file or directory this path points to (same as the last segment).
- Path:HASEXTENSION¶
- Type
- Access
Get only
True if the last segment of this path has an extension.
- Path:ROOT¶
- Type
- Access
Get only
Returns a new path that points to the root directory of this path’s volume.
- Path:PARENT¶
- Type
- Access
Get only
Returns a new path that points to this path’s parent. This method will throw an exception if this path does not have a parent (its length is 0).
- Path:CHANGENAME(name)¶
-
Will return a new path with the value of the last segment of this path replaced (or added if there’s none).
- Path:CHANGEEXTENSION(extension)¶
-
Will return a new path with the extension of the last segment of this path replaced (or added if there’s none).
- Path:ISPARENT(path)¶
-
Returns true if path is the parent of this path.
- Path:COMBINE(name1, [name2, ...])¶
-
Returns a new path that represents the file or directory that would be reached by starting from this path and then appending the path elements given in the list.
e.g:
set p to path("0:/home"). set p2 to p:combine("d1", "d2", "file.ks"). print p2 0:/home/d1/d2/file.ks