public class Path:
import klyn.io
project = Path.cwd
print(project)
print(project.name())
print(project.isDirectory)
rawPath = Path("unexisting-path")
print(type(rawPath)) # Path
print(rawPath.exists) # false
existing = Path.get("README.txt")
print(type(existing)) # FilePath or FolderPath| Modifier and Type | Member | Description |
|---|---|---|
| public static native readonly property | cwdcwd as FolderPath |
Current working directory. |
| public native readonly property | existsexists as Boolean |
Returns `true` if the path exists. |
| public native readonly property | isAbsoluteisAbsolute as Boolean |
Returns `true` if the path string is absolute. |
| public native readonly property | isDirectoryisDirectory as Boolean |
Returns `true` if the path exists and is a directory. |
| public native readonly property | isNormalizedisNormalized as Boolean |
Returns `true` if the path string is already normalized. |
| public native readonly property | isRegularisRegular as Boolean |
Returns `true` if the path exists and is a regular file. |
| public native readonly property | isSymlinkisSymlink as Boolean |
Returns `true` if the path is a symbolic link. |
| public static readonly property | klynHomeklynHome as FolderPath: |
Root directory of the Klyn installation/runtime. |
| public native readonly property | lastModifiedlastModified as Long |
Returns the last modification timestamp in milliseconds since Unix epoch. |
| public static readonly property | tempDirtempDir as FolderPath: |
OS temporary directory. |
| public static readonly property | userHomeuserHome as FolderPath: |
Home directory of the current user. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | Path | Creates a raw path object from a path string, even if the path does not exist. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | absoluteabsolute() as Path: |
Compatibility alias of `toAbsolute()`. |
| public | deletedelete() throws IOException: |
Compatibility alias of `remove()`. |
| public | endsWith | Returns `true` if this path ends with the given path string suffix. |
| public native | extensionextension() as String |
Returns the file extension without the leading dot, or `""`. |
| public static | file | Builds a file path from a base path and multiple segments. |
| public static | folderfolder(base as Path, names... as String) as FolderPath: |
Builds a folder path from a base path and multiple segments. |
| public static | get | Resolves an existing filesystem path and returns a typed path instance. |
| public native | lastModifiedlastModified() as Long |
Compatibility method alias for `lastModified`. |
| public native | namename() as String |
Returns the final path segment. |
| public native | normalizenormalize() as Path |
Returns a normalized path. |
| public native | parentparent() as Path |
Returns the parent path if available. |
| public native | relativize | Returns a path relative to the given base path. |
| public native | removeremove() throws IOException |
Removes the file or empty folder. |
| public native | renamerename(newName as String) throws IOException |
Renames the path. |
| public native | resolve | Resolves a child path against this path. |
| public | resolve | Resolves multiple child segments against this path. |
| public | resolve | Resolves another path against this path. |
| public static | resolve | Resolves multiple path segments against a base path. |
| public | startsWith | Returns `true` if this path starts with the given prefix (`Path` or `String`). |
| public native | toAbsolutetoAbsolute() as Path |
Returns an absolute version of the path. |
| public override | toStringtoString() as String: |
Returns the raw path string. |
| public native | touchtouch() as Void throws IOException |
Creates a file when missing or updates its modification date. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | operator!=(left as Path, right as Path) as Boolean: | Negated path equality. |
| public static | operator==(left as Path, right as Path) as Boolean: | Compares two paths by normalized absolute textual representation. |