Metadata.ts overview
Metadata schemas for virtual filesystem objects: timestamps, permission modes, the metadata record every observation returns, and the owner and time updates that mutations accept.
Since v0.6.0
constants
S_IFDIR
File-type bits of a directory in a POSIX st_mode.
Signature
declare const S_IFDIR: 16384Since v0.6.0
S_IFLNK
File-type bits of a symbolic link in a POSIX st_mode.
Signature
declare const S_IFLNK: 40960Since v0.6.0
S_IFMT
Mask of the file-type bits in a POSIX st_mode.
Signature
declare const S_IFMT: 61440Since v0.6.0
S_IFREG
File-type bits of a regular file in a POSIX st_mode.
Signature
declare const S_IFREG: 32768Since v0.6.0
getters
typedMode
The POSIX st_mode of an object: the file-type bits of its kind joined
with its permission mode. mode itself never carries type bits, so the
kind has a single source.
A volume has no device nodes, so a stat built from metadata reports dev
and rdev as 0, and (dev, ino) identifies an object only within one volume.
Example
import { S_IFDIR, S_IFMT, typedMode } from "@effect-vfs/core/Metadata"
const stMode = typedMode({ kind: "directory", mode: 0o755 })
console.log(stMode.toString(8)) // "40755"
console.log((stMode & S_IFMT) === S_IFDIR) // trueSignature
declare const typedMode: (metadata: Pick<Metadata, "kind" | "mode">) => numberSince v0.6.0
models
Metadata (type alias)
Metadata of a filesystem object, including its revision.
Signature
export type Metadata = {
readonly kind: "file" | "directory" | "symlink"
readonly ino: bigint
readonly nlink: number
readonly size: bigint
readonly uid: number
readonly gid: number
readonly mode: number
readonly atimeNs: bigint
readonly mtimeNs: bigint
readonly ctimeNs: bigint
readonly birthtimeNs: bigint
readonly revision: bigint
}Since v0.6.0
Mode (type alias)
A POSIX permission mode.
Signature
export type Mode = numberSince v0.6.0
OwnerUpdate (type alias)
An ownership update.
Signature
export type OwnerUpdate = { readonly uid?: number; readonly gid?: number }Since v0.6.0
TimeUpdate (type alias)
One timestamp update.
Signature
export type TimeUpdate =
| { readonly kind: "now" }
| { readonly kind: "omit" }
| { readonly kind: "value"; readonly nanoseconds: bigint }Since v0.6.0
Times (type alias)
Access and modification time updates.
Signature
export type Times = {
readonly access:
| { readonly kind: "now" }
| { readonly kind: "omit" }
| { readonly kind: "value"; readonly nanoseconds: bigint }
readonly modification:
| { readonly kind: "now" }
| { readonly kind: "omit" }
| { readonly kind: "value"; readonly nanoseconds: bigint }
}Since v0.6.0
Timestamp (type alias)
A timestamp in nanoseconds since the Unix epoch.
Signature
export type Timestamp = bigintSince v0.6.0
schemas
Metadata
Schema for the metadata of a filesystem object.
Signature
declare const Metadata: Schema.Struct<{
readonly kind: Schema.Literals<readonly ["directory", "file", "symlink"]>
readonly ino: Schema.BigInt
readonly nlink: Schema.Natural
readonly size: Schema.BigInt
readonly uid: Schema.Natural
readonly gid: Schema.Natural
readonly mode: Schema.Natural
readonly atimeNs: Schema.BigInt
readonly mtimeNs: Schema.BigInt
readonly ctimeNs: Schema.BigInt
readonly birthtimeNs: Schema.BigInt
readonly revision: Schema.BigInt
}>Since v0.6.0
Mode
Schema for a POSIX permission mode: the permission, setuid, setgid and sticky bits without any file-type bits.
Signature
declare const Mode: Schema.NaturalSince v0.6.0
OwnerUpdate
Schema for an ownership update; an omitted field keeps its current value.
Signature
declare const OwnerUpdate: Schema.Struct<{
readonly uid: Schema.optionalKey<Schema.Natural>
readonly gid: Schema.optionalKey<Schema.Natural>
}>Since v0.6.0
TimeUpdate
Schema for one timestamp update: the current time, no change, or an explicit value.
Signature
declare const TimeUpdate: Schema.Union<
readonly [
Schema.Struct<{ readonly kind: Schema.Literal<"now"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"omit"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"value">; readonly nanoseconds: Schema.BigInt }>
]
>Since v0.6.0
Times
Schema for the access and modification time updates a mutation applies together.
Signature
declare const Times: Schema.Struct<{
readonly access: Schema.Union<
readonly [
Schema.Struct<{ readonly kind: Schema.Literal<"now"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"omit"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"value">; readonly nanoseconds: Schema.BigInt }>
]
>
readonly modification: Schema.Union<
readonly [
Schema.Struct<{ readonly kind: Schema.Literal<"now"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"omit"> }>,
Schema.Struct<{ readonly kind: Schema.Literal<"value">; readonly nanoseconds: Schema.BigInt }>
]
>
}>Since v0.6.0
Timestamp
Schema for a timestamp in nanoseconds since the Unix epoch. Values stay within 128 decimal digits so they round-trip through snapshot encodings.
Signature
declare const Timestamp: Schema.BigIntSince v0.6.0