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.
Name Description
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.
Name Description
Directory Provides capabilities such as creating, querying, and traversing a directory in a file system.
File Provides functions for performing operations on files, including opening, creating, closing, and querying files, and reading and writing files using a stream.
HardLink Provides APIs for processing hard links of the file system.
SymbolicLink Provides APIs for processing symbolic links of the file system.
Name Description
OpenMode Indicates different file opening modes.
Name Description
FileDescriptor Obtains the file handle information.
FileInfo Provides functions for querying and setting file attributes for file metadata in a file system.
Path Provides path-related functions.
Name Description
FSException Specifies the file stream exception class and inherits the IOException class.