FileSystem
An interface providing basic operations on a filesystem, such as reading and writing files, creating directories, gathering file metadata and so on.
Default implementation of this interface is SystemFileSystem. It provides access to files and directories on disk.
The interface is sealed until API stabilization, but in the future it will allow creating custom filesystems that could be used as mocks for testing or provide access to some network resources and allow working with them as with regular files, for example.
This API is unstable and subject to change.
Thread-safety guarantees
Until stated otherwise, FileSystem implementation are not thread safe. If a FileSystem needs to be accessed from multiple threads, an additional synchronization is required.
Functions
Atomically renames source to destination overriding destination if it already exists.
Creates a directory tree represented by the path. If path already exists then the method throws kotlinx.io.IOException when mustCreate is true
. The call will attempt to create only missing directories. The method is not atomic and if it fails after creating some directories, these directories will not be deleted automatically. Permissions for created directories are platform-specific.
Return FileMetadata associated with a file or directory the path points to. If there is no such file or directory, or it's impossible to fetch metadata, null
is returned.
Returns an absolute path to the same file or directory the path is pointing to. All symbolic links are solved, extra path separators and references to current (.
) or parent (..
) directories are removed. If the path is a relative path then it'll be resolved against current working directory. If there is no file or directory to which the path is pointing to then FileNotFoundException will be thrown.