structstd.fs.File.Permissions[src]

Cross-platform representation of permissions on a file. The readonly and setReadonly are the only methods available across all platforms. Platform-specific functionality is available through the inner field.

Fields

inner: switch (builtin.os.tag) {
    .windows => PermissionsWindows,
    else => PermissionsUnix,
}

You may use the inner field to use platform-specific functionality

Functions

FunctionreadOnly[src]

pub fn readOnly(self: Self) bool

Returns true if permissions represent an unwritable file. On Unix, true is returned only if no class has write permissions.

Parameters

self: Self

Source Code

Source code
pub fn readOnly(self: Self) bool {
    return self.inner.readOnly();
}

FunctionsetReadOnly[src]

pub fn setReadOnly(self: *Self, read_only: bool) void

Sets whether write permissions are provided. On Unix, this affects all classes. If this is undesired, use unixSet. This method DOES NOT set permissions on the filesystem: use File.setPermissions(permissions)

Parameters

self: *Self
read_only: bool

Source Code

Source code
pub fn setReadOnly(self: *Self, read_only: bool) void {
    self.inner.setReadOnly(read_only);
}

Source Code

Source code
pub const Permissions = struct {
    /// You may use the `inner` field to use platform-specific functionality
    inner: switch (builtin.os.tag) {
        .windows => PermissionsWindows,
        else => PermissionsUnix,
    },

    const Self = @This();

    /// Returns `true` if permissions represent an unwritable file.
    /// On Unix, `true` is returned only if no class has write permissions.
    pub fn readOnly(self: Self) bool {
        return self.inner.readOnly();
    }

    /// Sets whether write permissions are provided.
    /// On Unix, this affects *all* classes. If this is undesired, use `unixSet`.
    /// This method *DOES NOT* set permissions on the filesystem: use `File.setPermissions(permissions)`
    pub fn setReadOnly(self: *Self, read_only: bool) void {
        self.inner.setReadOnly(read_only);
    }
}