Metadata structv0.1.0

Source
Everything a single query can say about a file.
pub struct Metadata {
    pub kind: FileKind;
    pub size: uint64;
    pub linkCount: uint64;
    pub permissions: Permissions;
    pub accessed: Timestamp;
    pub modified: Timestamp;
    pub hasCreated: bool;
    // private fields
}

Fields

NameTypeDescription
kindFileKindWhat the name refers to.
sizeuint64The length in bytes; zero for a directory, whose size means nothing portable.
linkCountuint64How many names the content has. Always one on a system that does not count them.
permissionsPermissionsWho may do what.
accessedTimestampWhen the contents were last read.
modifiedTimestampWhen the contents were last written.
hasCreatedboolWhether created means anything.

FileKind

pub enum FileKind: int32 {
    File = 0,
    Directory = 1,
    SymbolicLink = 2,
    Other = 3
}

What kind of thing a name refers to.

Source

Cases

NameValueDescription
File0An ordinary file of bytes.
Directory1A directory.
SymbolicLink2A symbolic link — only ever reported by a no-follow query, since following one lands on its target.
Other3A device, socket, pipe, or anything else the filesystem holds that is none of the above.

MetadataOf

pub func MetadataOf(
    allocator: Allocator,
    path: Path,
    followLinks: bool
) -> Metadata ! IoError

Describes the file path names. followLinks decides what a symbolic link at the end of the path means: following it describes the target, and not following it describes the link, which is the only way SymbolicLink is ever reported.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe path to act on
followLinksboolwhether a final symbolic link is followed rather than described

Returns: what the system knows about the path

SetTimes

pub func SetTimes(
    allocator: Allocator,
    path: Path,
    accessed: Timestamp,
    modified: Timestamp,
    followLinks: bool
) -> ! IoError

Sets the access and modification times of the file path names. Creation time is not settable here: Windows would allow it and the Unix systems would not, and an operation that silently means different things on different systems is worse than one that is not offered.

Source

Parameters

NameTypeDescription
allocatorAllocatorwhere the storage comes from
pathPaththe path to act on
accessedTimestampthe access time to set, or None to leave it
modifiedTimestampthe modification time to set, or None to leave it
followLinksboolwhether a final symbolic link is followed rather than described

Returns: success when the times were applied