IO.Path
The IO.Path
(alias io.path
) class provides a collection of static methods and properties for working with file and directory paths. It includes utility functions for manipulating file paths, retrieving directory information, and checking file system attributes.
Static Properties:
tmpdir or tempDirectory: string
The path to the system's temporary directory.picturesDirectory: string
The path to the system's pictures directory.musicDirectory: string
The path to the system's music directory.videosDirectory: string
The path to the system's videos directory.documentsDirectory: string
The path to the system's documents directory.downloadsDirectory: string
The path to the system's downloads directory.delimiter: string
The platform-specific path delimiter (e.g.,":"
on Unix,";"
on Windows).separator: string
The platform-specific directory separator (e.g.,"/"
on Unix,"\\"
on Windows).
Static Methods:
dir(path: string): string
Returns the directory part of the specified path.fileName(path: string, noext?: boolean): string
Returns the file name from the specified path. Ifnoext
istrue
, the file extension is removed (Default isfalse
)root(path: string): string
Returns the root part of the specified path (e.g.,"C:\"
on Windows).ext(path: string): string
Returns the file extension from the specified file path.changeext(path: string, ext: string): string
Changes the extension of the specified file path.resolve(path: string): string
Resolves a relative path to an absolute path.join(...args: string[]): string
Joins all given path segments into a single path (using path separator).readdir(path: string, searchPattern?: string | '*' ): string[]
Reads the contents of a directory and returns an array of file names.isAbsolute(path: string): boolean
Checks whether the given path is an absolute path.isRelative(path: string): boolean
Checks whether the given path is a relative path.isFile(path: string): boolean
Checks whether the given path refers to a file and not a directory.isDir(path: string): boolean
Checks whether the given path refers to a directory and not a file.exists(path: string): boolean
Checks whether the given path exists.chmod(path: string, attrs: FileAttrbute[])
Changes attributes of the specified file or directory. PossibleFileAttrbute
values are:ReadOnly, Hidden, System, Directory, Archive, Normal, Temporary, Compressed, Offline, Encrypted, SymLink.
atime(path: string, utcTime?: boolean | false): Date
Returns the last access time of the specified file or directory.mtime(path: string, utcTime?: boolean | false): Date
Returns the last modification time of the specified file or directory.ctime(path: string, utcTime?: boolean | false): Date
Returns the creation time of the specified file or directory.getTempFile or getTmpFile(ext?: string | ".~tmp"): string
Returns a temporary file path with the given extension (default:".~tmp"
).