Metadata for a path in a virtual filesystem.
Deliberately not File.Stat: that struct is shaped around POSIX stat(2)
for real OS files (inode, uid, gid, links, major_device,
minor_device). For virtual backends — git blobs, S3 objects, in-memory
maps — those fields are meaningless and would be nil constantly. Better
to have a struct shaped to the abstraction.
Fields follow File.Stat conventions where they exist (type :: atom(),
not is_file :: boolean()).
Fields
:type— one of:regular,:directory,:symlink,:other.:size— bytes for files; backends typically return0for directories.:mtime—DateTime.t(). Backends without real mtimes (e.g. content-addressed git blobs) use a deterministic value such as the containing tree's commit time or epoch.:mode— POSIX permission bits when meaningful,nilwhen not (e.g. S3).
Summary
Functions
Build a directory stat.
Build a regular-file stat. Convenience constructor for backends that always
set type: :regular and don't track mode.
Types
@type t() :: %VFS.Stat{ mode: non_neg_integer() | nil, mtime: DateTime.t(), size: non_neg_integer(), type: type() }
@type type() :: :regular | :directory | :symlink | :other
The kind of filesystem entry.
Functions
@spec directory(DateTime.t(), non_neg_integer() | nil) :: t()
Build a directory stat.
Examples
iex> VFS.Stat.directory(~U[2026-05-01 12:00:00Z])
%VFS.Stat{type: :directory, size: 0, mtime: ~U[2026-05-01 12:00:00Z], mode: nil}
@spec regular(non_neg_integer(), DateTime.t(), non_neg_integer() | nil) :: t()
Build a regular-file stat. Convenience constructor for backends that always
set type: :regular and don't track mode.
Examples
iex> VFS.Stat.regular(42, ~U[2026-05-01 12:00:00Z])
%VFS.Stat{type: :regular, size: 42, mtime: ~U[2026-05-01 12:00:00Z], mode: nil}