XU XUv0.16.0

#io/fs

import: #io/fs

counts: 5 functions, 0 methods, 1 types, 0 constants, 2 method sets

Directory-tree view. Implementation is concrete os.DirFS; package functions take &os.DirFS. valid_path checks unrooted slash paths.

struct@ FS

XuAPI
struct@ FS {
    fn open(string) os.File
}

Purpose

Method set of fs.FS / fs.File (constraints only; no interface values).

Required methods

open fn open(string) os.File
Operation on FS: open resource or establish connection.

(FS) open

XuAPI
fn open(string) os.File

Purpose

Operation on FS: open resource or establish connection.

Parameters

self Self
The Self instance used by this call (value receiver).
string string
string (string)

Returns

os.File — a value of this type

struct@ File

XuAPI
struct@ File {
    fn read(int) string
    fn close() int
}

Purpose

Method-set constraint File.

Required methods

read fn read(int) string
Operation on File: read up to max bytes.
close fn close() int
Operation on File: close the resource.

(File) read

XuAPI
fn read(int) string

Purpose

Operation on File: read up to max bytes.

Parameters

self Self
The Self instance used by this call (value receiver).
int int
int (int)

Returns

string — result string

(File) close

XuAPI
fn close() int

Purpose

Operation on File: close the resource.

Parameters

self Self
The Self instance used by this call (value receiver).

Returns

int — a value of this type

struct DirEntry

XuAPI
pub struct DirEntry {
    pub name string
    pub is_dir bool
}

Purpose

Structure encapsulating name, is_dir.

Public fields

name string
name
is_dir bool
field (bool)

valid_path

XuAPI
pub fn valid_path(name &string) bool

Purpose

valid_path is fs.ValidPath: unrooted slash-separated name; "." is the only allowed "." / empty / ".." exception (the FS root).

Parameters

name &string
name (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

read_file

XuAPI
pub fn read_file(fsys &os.DirFS, name string) string

Purpose

Read file. Throws on failure; handle the error or propagate it to the caller.

Parameters

fsys &os.DirFS
fsys (read-only borrow; caller keeps the original; type &os.DirFS)
name string
name (string)

Returns

string — result string

read_dir

XuAPI
pub fn read_dir(fsys &os.DirFS, name string) []DirEntry

Purpose

Read directory. Throws on failure; handle the error or propagate it to the caller.

Parameters

fsys &os.DirFS
fsys (read-only borrow; caller keeps the original; type &os.DirFS)
name string
name (string)

Returns

[]DirEntry — slice result

stat

XuAPI
pub fn stat(fsys &os.DirFS, name string) FileInfo

Purpose

Read metadata. Throws on failure; handle the error or propagate it to the caller.

Parameters

fsys &os.DirFS
fsys (read-only borrow; caller keeps the original; type &os.DirFS)
name string
name (string)

Returns

FileInfo — a value of this type

sub

XuAPI
pub fn sub(fsys &os.DirFS, dir string) os.DirFS

Purpose

Subtract. Throws on failure; handle the error or propagate it to the caller.

Parameters

fsys &os.DirFS
fsys (read-only borrow; caller keeps the original; type &os.DirFS)
dir string
directory (string)

Returns

os.DirFS — a value of this type