Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

FileSystem

Owns cheap selected-provider capability observation. This stateless utility owns no native resource, current directory or mutable process state. Capabilities() allocates nothing and performs no native probe. The selected package determines the result; resource calls can still fail.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

Module std.fs

import std.fs;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

FileSystem

pub struct FileSystem

Owns cheap selected-provider capability observation. This stateless utility owns no native resource, current directory or mutable process state. Capabilities() allocates nothing and performs no native probe. The selected package determines the result; resource calls can still fail.

Example

module example.filesystem_capabilities;
from std.fs import FileSystem, File, Path;
fn Main() -> i32 {
    let Capabilities = FileSystem.Capabilities();
    var NativePath = {
        // Scoped writable carriers end immediately after explicit payload transfer.
        var NativePathCreation = Path.TryCreate("/dev/null");
        switch NativePathCreation {
            case .Ok { Value = Value: mut Path& } => break move(Value);
            case .Err => return 1;
        }
    };
    if !Capabilities.CanOpenFiles {
        // The explicit unavailable provider supplies no native resource requests.
        if Capabilities.CanEnumerateDirectories || Capabilities.CanReadMetadata ||
           Capabilities.CanChangeTimes || Capabilities.CanChangePosixMode ||
           Capabilities.CanChangePosixOwnership || Capabilities.CanUseExtendedAttributes ||
           Capabilities.CanUsePosixAcls { return 6; }
        // This provider has no filesystem; path values still work without I/O.
        switch File.TryOpen(NativePath.View) {
            case .Err { Error = PatternPayload5069 } => {
                switch PatternPayload5069 {
                    case .Failure { Reason = PatternPayload5070 } if (PatternPayload5070 is .UnsupportedOperation) => return 0;
                    default => return 2;
                }
            }
            default => return 2;
        }
    }
    // An implemented request can still fail: always check its actual result.
    var Opened = {
        var OpenedCreation = File.TryOpen(NativePath.View);
        switch OpenedCreation {
            case .Ok { Value = Value: mut File& } => break move(Value);
            case .Err => return 3;
        }
    };
    let Metadata = Opened.ReadMetadata();
    let Closed = Opened.Close();
    if Metadata is .Err { Error = _ } { return 4; }
    if Closed is .Err { Error = _ } { return 5; }
    return 0;
}

FileSystem.fn

pub static const fn Capabilities() -> FileSystemCapabilities

Observes implemented requests without I/O or allocation. Return: Detached immutable selection snapshot; not an authorization promise.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library