Path

class Path : Comparable<Path>

A hierarchical identifier for a file in a file system.

A path consists of a root URI and a list of names. The root URI identifies the root of the file hierarchy, including the file system which is identified by the scheme of the root URI. The list of names identifies the file within its file hierarchy, and each name is a non-empty byte string that doesn't contain the URI path separator /.

As such, a path is always absolute, and a relative identifier consisting of only a list of names is represented by a RelativePath.

A path is an immutable data object independent of file systems, and can be converted to/from a URI for presentation and serialization.

See also

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val fileName: ByteString?

The file name of this path, which is the last name in the list of names.

Link copied to clipboard

A tag for use by the implementation of the file system identified by this path.

Link copied to clipboard
val names: List<ByteString>

The list of names of this path.

Link copied to clipboard

The root URI of this path.

Link copied to clipboard

The scheme of the root URI of this path.

Functions

Link copied to clipboard
inline suspend fun Path.checkAccess(vararg modes: AccessMode)
Link copied to clipboard
open operator override fun compareTo(other: Path): Int
Link copied to clipboard
inline suspend fun Path.copyTo(target: Path, vararg options: CopyFileOption)
Link copied to clipboard
inline suspend fun Path.createDirectory(vararg options: CreateFileOption)
Link copied to clipboard
inline suspend fun Path.createHardLinkTo(existing: Path)
Link copied to clipboard
inline suspend fun Path.createSymbolicLinkTo(target: ByteString, vararg options: CreateFileOption)
Link copied to clipboard
inline suspend fun Path.delete()
Link copied to clipboard
inline suspend fun Path.deleteIfExists(): Boolean
Link copied to clipboard

Check whether this path ends with a relative path.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
inline suspend fun Path.exists(noFollowLinks: Boolean = false): Boolean
Link copied to clipboard
fun getParent(): Path?

Get a path for the parent of the file this path is identifying, or null if this path identifies the root of its file hierarchy.

Link copied to clipboard
fun getRoot(): Path

Get a path for the root of the file hierarchy this path is identifying.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
inline suspend fun Path.isAccessible(vararg modes: AccessMode): Boolean
Link copied to clipboard
inline suspend fun Path.isSameFileAs(other: Path): Boolean
Link copied to clipboard
inline suspend fun Path.moveTo(target: Path, vararg options: CopyFileOption)
Link copied to clipboard

Get a path that is this path with redundant names removed.

Link copied to clipboard
inline suspend fun Path.notExists(noFollowLinks: Boolean = false): Boolean
Link copied to clipboard
inline suspend fun Path.openContent(vararg options: FileContentOption): FileContent
Link copied to clipboard
inline suspend fun Path.openDirectoryStream(vararg options: DirectoryStreamOption): DirectoryStream
Link copied to clipboard
inline suspend fun Path.openFileStore(): FileStore
Link copied to clipboard
inline suspend fun Path.openMetadataView(vararg options: FileMetadataOption): FileMetadataView
Link copied to clipboard
inline suspend fun Path.openSink(vararg options: FileContentOption = FileSystem.OPEN_SINK_OPTIONS_DEFAULT): AsyncSink
Link copied to clipboard
inline suspend fun Path.openSource(vararg options: FileContentOption): AsyncSource
Link copied to clipboard
inline suspend fun Path.readDirectory(vararg options: DirectoryStreamOption): List<Path>
Link copied to clipboard
inline suspend fun Path.readMetadata(vararg options: FileMetadataOption): FileMetadata
Link copied to clipboard
inline suspend fun Path.readSymbolicLink(): ByteString
Link copied to clipboard

Get a relative path between this path and another path.

Link copied to clipboard
Link copied to clipboard
fun resolve(fileName: ByteString): Path

Resolve a file name against this path.

Resolve a relative path against this path.

Link copied to clipboard
fun resolveSibling(fileName: ByteString): Path

Resolve a file name against the parent of this path.

Link copied to clipboard
fun startsWith(other: Path): Boolean

Check whether this path starts with another path.

Link copied to clipboard
fun subPath(endIndex: Int): Path

Get a path consisting of a sublist of names of this path.

Link copied to clipboard
fun Path.toPlatformPath(): ByteString
Link copied to clipboard
Link copied to clipboard
inline suspend fun Path.toRealPath(): Path
Link copied to clipboard
fun toRelativePath(startIndex: Int = 0, endIndex: Int = names.size): RelativePath

Get a relative path consisting of a sublist of names of this path.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun toUri(): Uri

Get a URI representing this path.