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
Volume
Volume this path belongs to SEGMENTS
List
ofString
List of this path’s segments LENGTH
Scalar
Number of segments in this path NAME
String
Name of file or directory this path points to HASEXTENSION
Boolean
True if path contains an extension EXTENSION
String
This path’s extension ROOT
Path
Root path of this path’s volume PARENT
Path
Parent path CHANGENAME(name)
Path
Returns a new path with its name (last segment) changed CHANGEEXTENSION(extension)
Path
Returns a new path with extension changed ISPARENT(path)
Boolean
True if path is the parent of this path COMBINE(name1, [name2, ...])
Path
Returns a new path created by adding further elements to this one
-
Path:
SEGMENTS
¶ Type: List
ofString
Access: Get only 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: String
Access: Get only Name of file or directory this path points to (same as the last segment).
-
Path:
HASEXTENSION
¶ Type: Boolean
Access: Get only True if the last segment of this path has an extension.
-
Path:
ROOT
¶ Type: Path
Access: Get only Returns a new path that points to the root directory of this path’s volume.
-
Path:
PARENT
¶ Type: Path
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)¶ Parameters: - name –
String
new path name
Returns: Will return a new path with the value of the last segment of this path replaced (or added if there’s none).
- name –
-
Path:
CHANGEEXTENSION
(extension)¶ Parameters: - extension –
String
new path extension
Returns: Will return a new path with the extension of the last segment of this path replaced (or added if there’s none).
- extension –
-
Path:
ISPARENT
(path)¶ Parameters: - path –
Path
path to check
Returns: Returns true if path is the parent of this path.
- path –
-
Path:
COMBINE
(name1, [name2, ...])¶ Parameters: - name –
String
segments to add
Returns: 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
- name –