Metadata structv0.1.0
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
| Name | Type | Description |
|---|---|---|
kind | FileKind | What the name refers to. |
size | uint64 | The length in bytes; zero for a directory, whose size means nothing portable. |
linkCount | uint64 | How many names the content has. Always one on a system that does not count them. |
permissions | Permissions | Who may do what. |
accessed | Timestamp | When the contents were last read. |
modified | Timestamp | When the contents were last written. |
hasCreated | bool | Whether created means anything. |
Related
FileKind
pub enum FileKind: int32 {
File = 0,
Directory = 1,
SymbolicLink = 2,
Other = 3
}
What kind of thing a name refers to.
Cases
| Name | Value | Description |
|---|---|---|
File | 0 | An ordinary file of bytes. |
Directory | 1 | A directory. |
SymbolicLink | 2 | A symbolic link — only ever reported by a no-follow query, since following one lands on its target. |
Other | 3 | A 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.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
followLinks | bool | whether 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.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
accessed | Timestamp | the access time to set, or None to leave it |
modified | Timestamp | the modification time to set, or None to leave it |
followLinks | bool | whether a final symbolic link is followed rather than described |
Returns: success when the times were applied