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 VOLUMEVolumeVolume this path belongs to SEGMENTSListofStringList of this path’s segments LENGTHScalarNumber of segments in this path NAMEStringName of file or directory this path points to HASEXTENSIONBooleanTrue if path contains an extension EXTENSIONStringThis path’s extension ROOTPathRoot path of this path’s volume PARENTPathParent path CHANGENAME(name)PathReturns a new path with its name (last segment) changed CHANGEEXTENSION(extension)PathReturns a new path with extension changed ISPARENT(path)BooleanTrue if path is the parent of this path COMBINE(name1, [name2, ...])PathReturns a new path created by adding further elements to this one
-
Path:
SEGMENTS¶ Type: ListofStringAccess: 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: StringAccess: Get only Name of file or directory this path points to (same as the last segment).
-
Path:
HASEXTENSION¶ Type: BooleanAccess: Get only True if the last segment of this path has an extension.
-
Path:
ROOT¶ Type: PathAccess: Get only Returns a new path that points to the root directory of this path’s volume.
-
Path:
PARENT¶ Type: PathAccess: 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 –
Stringnew 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 –
Stringnew 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 –
Pathpath to check
Returns: Returns true if path is the parent of this path.
- path –
-
Path:
COMBINE(name1, [name2, ...])¶ Parameters: - name –
Stringsegments 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 –