FileMetadata

class FileMetadata(isRegularFile: Boolean, isDirectory: Boolean, size: Long?, createdAtMillis: Long?, lastModifiedAtMillis: Long?, lastAccessedAtMillis: Long?)

Description of a file or another object referenced by a path.

In simple use a file system is a mechanism for organizing files and directories on a local storage device. In practice file systems are more capable and their contents more varied. For example, a path may refer to:

  • An operating system process that consumes data, produces data, or both. For example, reading from the /dev/urandom file on Linux returns a unique sequence of pseudorandom bytes to each reader.

  • A stream that connects a pair of programs together. A pipe is a special file that a producing program writes to and a consuming program reads from. Both programs operate concurrently. The size of a pipe is not well defined: the writer can write as much data as the reader is able to read.

  • A file on a remote file system. The performance and availability of remote files may be quite different from that of local files!

  • A symbolic link (symlink) to another path. When attempting to access this path the file system will follow the link and return data from the target path.

  • The same content as another path without a symlink. On UNIX file systems an inode is an anonymous handle to a file's content, and multiple paths may target the same inode without any other relationship to one another. A consequence of this design is that a directory with three 1 GiB files may only need 1 GiB on the storage device.

This class does not attempt to model these rich file system features! It exposes a limited view useful for programs with only basic file system needs. Be cautious of the potential consequences of special files when writing programs that operate on a file system.

File metadata is subject to change, and code that operates on file systems should defend against changes to the file that occur between reading metadata and subsequent operations.

Constructors

FileMetadata
Link copied to clipboard
common
fun FileMetadata(isRegularFile: Boolean, isDirectory: Boolean, size: Long?, createdAtMillis: Long?, lastModifiedAtMillis: Long?, lastAccessedAtMillis: Long?)

Functions

equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

createdAtMillis
Link copied to clipboard
common
val createdAtMillis: Long?
Returns the system time of the host computer when this file was created, if the host file system supports this feature.
isDirectory
Link copied to clipboard
common
val isDirectory: Boolean
True if the path refers to a directory that contains 0 or more child paths.
isRegularFile
Link copied to clipboard
common
val isRegularFile: Boolean
True if this file is a container of bytes.
lastAccessedAtMillis
Link copied to clipboard
common
val lastAccessedAtMillis: Long?
Returns the system time of the host computer when this file was most recently read or written.
lastModifiedAtMillis
Link copied to clipboard
common
val lastModifiedAtMillis: Long?
Returns the system time of the host computer when this file was most recently written.
size
Link copied to clipboard
common
val size: Long?
Returns the number of bytes readable from this file.