class Path:
A file system path.
func __init__(self, path: string):
func ==(self, other: Path) -> bool:
func !=(self, other: Path) -> bool:
func name(self) -> string:
The final component.
func stem(self) -> string:
The final component without extension.
func extension(self) -> string:
The final component extension, including the dot.
func parent(self) -> Path:
The parent path.
func join(self, other: string) -> Path:
Join with other path.
func join(self, other: Path) -> Path:
Join with other path.
func is_absolute(self) -> bool:
Check if absolute.
func is_relative(self) -> bool:
Check if relative.
func with_name(self, name: string) -> Path:
Returns a new path with given name.
func with_stem(self, stem: string) -> Path:
Returns a new path with given stem.
func with_extension(self, extension: string) -> Path:
Returns a new path with given extension.
func read_text(self) -> string:
Read file contents.
func write_text(self, data: string):
Write file contents.
func read_binary(self) -> bytes:
Read file contents.
func write_binary(self, data: bytes):
Write file contents.
func open_binary(self, mode: string = "r") -> BinaryFile:
Open binary file.
func open_text(self, mode: string = "r") -> TextFile:
Open binary file.
func exists(self) -> bool:
Check for existence.
func mkdir(self, exists_ok: bool = False):
Create directories.
Give `exists_ok` as ``True`` to ignore errors.
func chmod(self, mode: u32):
Change permissions.
func ls(self) -> [Path]:
Returns all files and folders.
func rm(self, recursive: bool = False, force: bool = False):
Remove files and directories.
Give `recursive` as ``True`` to remove all files and folders
recursivly.
Give `force` as ``True`` to ignore errors.
func touch(self):
Update modification time and creates if missing.
func cd(self):
Change directory.
func cp(self, dst: Path, recursive: bool = False):
Copy files and directories.
func mv(self, dst: Path):
Move files and directories.
func to_string(self) -> string:
Return the path as a string.