std.fs

Function Description

The file system (fs) package provides functions for operating files, folders, paths, and file metadata.

Currently, the fs package can be used in Linux, macOS, Windows and HarmonyOS.

API List

Function

NameDescription
canonicalize(Path)Normalizes a path instance and obtains the normalized path in the form of an absolute path.
canonicalize(String)Constructs a path instance using the path string, normalizes the instance, and obtains the normalized path in the form of an absolute path.
copy(Path, Path, Bool)Implements the copy function of the file system for replication of files or directories.
copy(String, String, Bool)Implements the copy function of the file system for replication of files or directories.
exists(Path)Checks whether the target address exists.
exists(String)Checks whether the target address exists.
rename(Path, Path, Bool)Renames a file.
rename(String, String, Bool)Renames a file.
remove(Path, Bool)Deletes a file or directory.
remove(String, Bool)Deletes a file or directory.
removeIfExists(Path, Bool)Checks whether the target exists. If the target exists, it is deleted.
removeIfExists(String, Bool)Checks whether the target exists. If the target exists, it is deleted.

Class

NameDescription
DirectoryProvides capabilities such as creating, querying, and traversing a directory in a file system.
FileProvides functions for performing operations on files, including opening, creating, closing, and querying files, and reading and writing files using a stream.
HardLinkProvides APIs for processing hard links of the file system.
SymbolicLinkProvides APIs for processing symbolic links of the file system.

Enumeration

NameDescription
OpenModeIndicates different file opening modes.

Struct

NameDescription
FileDescriptorObtains the file handle information.
FileInfoProvides functions for querying and setting file attributes for file metadata in a file system.
PathProvides path-related functions.

Exception Class

NameDescription
FSExceptionSpecifies the file stream exception class and inherits the IOException class.