structstd.fs.File.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.

Functions

Functionsize[src]

pub fn size(self: Self) u64

Returns the size of the file

Parameters

self: Self

Source Code

Source code
pub fn size(self: Self) u64 {
    return self.inner.size();
}

Functionpermissions[src]

pub fn permissions(self: Self) Permissions

Returns a Permissions struct, representing the permissions on the file

Parameters

self: Self

Source Code

Source code
pub fn permissions(self: Self) Permissions {
    return self.inner.permissions();
}

Functionkind[src]

pub fn kind(self: Self) Kind

Returns the Kind of file. On Windows, can only return: .file, .directory, .sym_link or .unknown

Parameters

self: Self

Source Code

Source code
pub fn kind(self: Self) Kind {
    return self.inner.kind();
}

Functionaccessed[src]

pub fn accessed(self: Self) i128

Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01

Parameters

self: Self

Source Code

Source code
pub fn accessed(self: Self) i128 {
    return self.inner.accessed();
}

Functionmodified[src]

pub fn modified(self: Self) i128

Returns the time the file was modified in nanoseconds since UTC 1970-01-01

Parameters

self: Self

Source Code

Source code
pub fn modified(self: Self) i128 {
    return self.inner.modified();
}

Functioncreated[src]

pub fn created(self: Self) ?i128

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

Parameters

self: Self

Source Code

Source code
pub fn created(self: Self) ?i128 {
    return self.inner.created();
}

Source Code

Source code
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();
    }
}