struct Metadata [src]
Cross-platform representation of file metadata.
Platform-specific functionality is available through the inner field.
Fields
inner: switch (builtin.os.tag) {
.windows => MetadataWindows,
.linux => MetadataLinux,
.wasi => MetadataWasi,
else => MetadataUnix,
}Exposes platform-specific functionality.
Members
Source
pub const Metadata = struct {
/// Exposes platform-specific functionality.
inner: switch (builtin.os.tag) {
.windows => MetadataWindows,
.linux => MetadataLinux,
.wasi => MetadataWasi,
else => MetadataUnix,
},
const Self = @This();
/// Returns the size of the file
pub fn size(self: Self) u64 {
return self.inner.size();
}
/// Returns a `Permissions` struct, representing the permissions on the file
pub fn permissions(self: Self) Permissions {
return self.inner.permissions();
}
/// Returns the `Kind` of file.
/// On Windows, can only return: `.file`, `.directory`, `.sym_link` or `.unknown`
pub fn kind(self: Self) Kind {
return self.inner.kind();
}
/// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
pub fn accessed(self: Self) i128 {
return self.inner.accessed();
}
/// Returns the time the file was modified in nanoseconds since UTC 1970-01-01
pub fn modified(self: Self) i128 {
return self.inner.modified();
}
/// Returns the time the file was created in nanoseconds since UTC 1970-01-01
/// On Windows, this cannot return null
/// On Linux, this returns null if the filesystem does not support creation times
/// On Unices, this returns null if the filesystem or OS does not support creation times
/// On MacOS, this returns the ctime if the filesystem does not support creation times; this is insanity, and yet another reason to hate on Apple
pub fn created(self: Self) ?i128 {
return self.inner.created();
}
}