Module fs/file

fs/file
Stability: unstable — `flush` names the wrong operation. The inherent `File.flush(io)` is an `fsync`, which is Rust's `File::sync_all`, while this file's `io.Writer` impl gives the same spelling Rust's `Write::flush` meaning: a no-op, because an fd write is unbuffered. So `f.flush(io)` costs a disk barrier while the identical call inside a function bounded on `Writer` costs nothing, and nothing in the signature says which one a reader is looking at. Freezing follows splitting those into `sync_all` / `sync_data` (`fdatasync`) with `flush` left to the trait, not a release count. — stable modules only change additively; this one may still change.

Async file I/O operations with Exception-based error handling.

Wraps a file descriptor with typed async I/O operations. Uses the Exception effect for error handling.

Example

{ File, read_to_string, write_string, OpenMode } :: import "std/fs/file";

main :: (fn(io : Io, exn : Exception) -> unit)({
  // Write a file
  io.await(write_string(Path.new(`test.txt`), `hello world`, io), { io, exn });

  // Read it back
  content := io.await(read_to_string(Path.new(`test.txt`), io), { io, exn });
  println(content);

  // Open with OpenMode
  f := io.await(File.open(Path.new(`test.txt`), .Read, io), { io, exn });
});

Positions are per-handle, not per-descriptor

Every read and write goes through POSITIONAL I/O (pread/pwrite), so the descriptor's own file offset never moves and File._pos is the only authority on "where am I". Two consequences a caller cannot see from the signatures: seek/position are pure arithmetic on the handle and never reach the OS (which is why seek needs only exn, not io), and a File is a ref handle, so a copy of one SHARES the position — two interleaved async reads through the same handle read from wherever the other one left off, they do not each get their own cursor.

Stability

unstable — flush names the wrong operation. The inherent File.flush(io) is an fsync, which is Rust's File::sync_all, while this file's io.Writer impl gives the same spelling Rust's Write::flush meaning: a no-op, because an fd write is unbuffered. So f.flush(io) costs a disk barrier while the identical call inside a function bounded on Writer costs nothing, and nothing in the signature says which one a reader is looking at. Freezing follows splitting those into sync_all / sync_data (fdatasync) with flush left to the trait, not a release count.

Types

File object
File

An open file handle with async read/write operations.

Provides methods for reading, writing, seeking, and querying file metadata. Files are automatically closed when disposed.

Fields

NameTypeDescription
_fdi32
_pathPath
_is_closedbool
_posu64

Byte offset for the NEXT read/write_* on this handle.

File must carry its own position because the async runtime implements reads and writes with POSITIONAL I/O (pread/pwrite), which neither consults nor advances the descriptor's file position. Passing a constant 0 here is what made every read return the first bytes forever, every write_* overwrite at the start, and seek a silent no-op — issues/file-read-write-ignore-position-always-offset-zero.md.

One exception is deliberate: a handle opened .Append carries O_APPEND, and the kernel forces those writes to end-of-file whatever offset is supplied, so _pos does not govern them.

Trait Implementations

Dispose IoTraits
impl(File, ...)
open_with : (File) fn(path : Path, mode : OpenMode, perm : FilePermission, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file at path with the given mode and custom permissions.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

modeOpenMode
permFilePermission
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_with_str : (File) fn(path : str, mode : OpenMode, perm : FilePermission, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file from a str path with the given mode and custom permissions.

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

modeOpenMode
permFilePermission
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_with_cstr : (File) fn(path : *(u8), mode : OpenMode, perm : FilePermission, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file from a C string path with the given mode and custom permissions.

Parameters

NameTypeNotesDescription
path*(u8)

Get the path this file was opened with.

modeOpenMode
permFilePermission
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open : (File) fn(path : Path, mode : OpenMode, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file at path with the given mode and default permissions (0o644).

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

modeOpenMode
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_str : (File) fn(path : str, mode : OpenMode, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file from a str path with the given mode and default permissions.

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

modeOpenMode
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_opts_with : (File) fn(path : Path, opts : OpenOptions, perm : FilePermission, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file at path with an OpenOptions flag set and custom permissions.

perm is consulted only when opts.creates() — POSIX ignores the mode argument otherwise, so passing one for a non-creating open is silently meaningless and this mirrors that.

Throws when opts names a contradictory combination (see OpenOptions.to_flags): the thrown error is a Context carrying the explanation over an IoError.InvalidInput, so to_string() says which combination was rejected while source() still reports the kind Rust would report.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

optsOpenOptions
permFilePermission
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_opts : (File) fn(path : Path, opts : OpenOptions, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file at path with an OpenOptions flag set and default permissions (0o644).

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

optsOpenOptions
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

open_cstr : (File) fn(path : *(u8), mode : OpenMode, io : Io) -> Impl : (Future[Future](File) IoExn : IoExn)

Open a file from a C string path with the given mode and default permissions.

Parameters

NameTypeNotesDescription
path*(u8)

Get the path this file was opened with.

modeOpenMode
ioIo

Returns: Impl : (Future[Future](File) IoExn : IoExn)

read : (File) fn(self : File, buf : *(u8), size : usize, io : Io) -> Impl : (Future[Future](usize) IoExn : IoExn)

Read an entire file into a byte list (ArrayList(u8)).

Parameters

NameTypeNotesDescription
selfFile
buf*(u8)
sizeusize

Get the file size in bytes.

ioIo

Returns: Impl : (Future[Future](usize) IoExn : IoExn)

write : (File) fn(self : File, buf : *(u8), size : usize, io : Io) -> Impl : (Future[Future](usize) IoExn : IoExn)

Write bytes to a file, creating or truncating it.

Parameters

NameTypeNotesDescription
selfFile
buf*(u8)
sizeusize

Get the file size in bytes.

ioIo

Returns: Impl : (Future[Future](usize) IoExn : IoExn)

write_string : (File) fn(self : File, data : String, io : Io) -> Impl : (Future[Future](usize) IoExn : IoExn)

Write a String to a file, creating or truncating it.

Parameters

NameTypeNotes
selfFile
dataString
ioIo

Returns: Impl : (Future[Future](usize) IoExn : IoExn)

write_bytes : (File) fn(self : File, data : ArrayList(u8), io : Io) -> Impl : (Future[Future](usize) IoExn : IoExn)

Write bytes from an ArrayList(u8) to the file. Returns the number of bytes written.

Parameters

NameTypeNotes
selfFile
dataArrayList(u8)
ioIo

Returns: Impl : (Future[Future](usize) IoExn : IoExn)

flush : (File) fn(self : File, io : Io) -> Impl : (Future[Future](unit) IoExn : IoExn)

A no-op — Rust's Write::flush for File. An fd write has no user-space buffer behind it, so there is nothing to push. The inherent File.flush is an fsync instead; see its doc.

Parameters

NameTypeNotes
selfFile
ioIo

Returns: Impl : (Future[Future](unit) IoExn : IoExn)

set_len : (File) fn(self : File, length : i64, io : Io) -> Impl : (Future[Future](unit) IoExn : IoExn)

Truncate or extend the file to exactly length bytes (Rust's File::set_len). Extending pads with zeroes. Takes effect regardless of this handle's read/write position.

Parameters

NameTypeNotes
selfFile
lengthi64
ioIo

Returns: Impl : (Future[Future](unit) IoExn : IoExn)

from_fd : (File) fn(fd : i32) -> File

Wrap an ALREADY-OPEN file descriptor without opening anything (Rust's File::from for raw fds). The handle starts at position 0 — use seek() if the descriptor's data should be read from elsewhere. The path is unknown, so path() reports an empty path.

Parameters

NameTypeNotesDescription
fdi32

Get the underlying file descriptor.

Returns: File

seek : (File) fn(self : File, offset : i64, from : SeekFrom, exn : Exception) -> i64

Seek to a position relative to from. Returns the new absolute byte offset.

Parameters

NameTypeNotes
selfFile
offseti64
fromSeekFrom
exnException

Returns: i64

position : (File) fn(self : File) -> i64

Get the current file position (byte offset from the beginning).

Reports _pos, not the descriptor's position. This used to ask the descriptor via lseek(SEEK_CUR), which ALWAYS answered 0: positional reads and writes never move it.

Parameters

NameTypeNotes
selfFile

Returns: i64

rewind : (File) fn(self : File, exn : Exception) -> unit

Move back to the beginning of the file (Rust's Seek::rewind).

Inherent rather than a Seek default because a trait generic over the reference-point type cannot name its own "start" — see io.Seek.

Parameters

NameTypeNotes
selfFile
exnException

Returns: unit

size : (File) fn(self : File) -> i64

Get the file size in bytes.

Parameters

NameTypeNotes
selfFile

Returns: i64

close : (File) fn(self : File, io : Io) -> Impl : (Future[Future](unit) IoExn : IoExn)

Close the file descriptor. Safe to call multiple times.

Parameters

NameTypeNotes
selfFile
ioIo

Returns: Impl : (Future[Future](unit) IoExn : IoExn)

fd : (File) fn(self : File) -> i32

Get the underlying file descriptor.

Parameters

NameTypeNotes
selfFile

Returns: i32

path : (File) fn(self : File) -> Path

Get the path this file was opened with.

Parameters

NameTypeNotes
selfFile

Returns: Path

metadata : (File) fn(self : File, io : Io) -> Impl : (Future[Future](Metadata) IoExn : IoExn)

Get file metadata (size, permissions, timestamps).

fstats THIS handle's descriptor. It used to re-stat _path, which answered about a different inode the moment the two diverged: a from_fd handle has no path at all and an empty Path renders as ., so it reported the CURRENT DIRECTORY's size, mode and times with no error — issues/fixed/fs-metadata-restats-by-path-and-walker-drops-dt-unknown.md. A file renamed, replaced or unlinked after the open had the same problem. The descriptor names the inode; the path does not.

Parameters

NameTypeNotes
selfFile
ioIo

Returns: Impl : (Future[Future](Metadata) IoExn : IoExn)

impl(File, Dispose(...))
dispose : (File) fn(self : File) -> unit

Release the resources self owns — a file descriptor, a socket, a lock, a buffer the allocator handed out. Called automatically when the last reference to the value goes away, so an implementor never calls it directly and must tolerate being the only one who ever does.

It must be safe to run exactly once: the runtime calls it at refcount zero, and a type that also exposes an explicit close/release is responsible for making the second call a no-op.

Parameters

NameTypeNotes
selfFile

Returns: unit

impl(File, IoTraits)
impl(File, IoTraits)
impl(File, IoTraits)
Methods
read_to_end : (File) fn(self : File, io : Io) -> Impl : (Future[Future](ArrayList(u8)) IoExn : IoExn)

Parameters

NameTypeNotes
selfFile
ioIo

Returns: Impl : (Future[Future](ArrayList(u8)) IoExn : IoExn)

read_to_string : (File) fn(self : File, io : Io) -> Impl : (Future[Future](String) IoExn : IoExn)

Read an entire file into a String.

Parameters

NameTypeNotes
selfFile
ioIo

Returns: Impl : (Future[Future](String) IoExn : IoExn)

write_all : (File) fn(self : File, buf : *(u8), size : usize, io : Io) -> Impl : (Future[Future](unit) IoExn : IoExn)

Parameters

NameTypeNotesDescription
selfFile
buf*(u8)
sizeusize

Get the file size in bytes.

ioIo

Returns: Impl : (Future[Future](unit) IoExn : IoExn)

OpenMode enum
OpenMode

Determines how a file is opened.

Variants

VariantFieldsDescription
Read

Read an existing file (O_RDONLY).

Write

Create or overwrite a file (O_WRONLY | O_CREAT | O_TRUNC).

Append

Append to a file (O_WRONLY | O_CREAT | O_APPEND).

ReadWrite

Read and write an existing file (O_RDWR).

CreateNew

Create a new file, fail if it already exists (O_WRONLY | O_CREAT | O_EXCL).

OpenOptions struct
OpenOptions

A builder for the open flags — Rust's fs::OpenOptions.

OpenMode's five variants are the common combinations, and they cannot express the rest: there is no read+append, no create-without-truncate, no read+write+create. Rather than grow that enum combinatorially, this builds the flag set directly.

A plain value struct with functional setters, so a chain builds a new value at each step and nothing is shared or allocated:

f := io.await(
  File.open_opts(path, OpenOptions.new().read(true).append(true).create(true), io),
  { io, exn }
);

to_flags() resolves the POSIX flag set, and REJECTS the combinations POSIX would silently misinterpret rather than passing them through.

Fields

NameTypeDescription
_readbool
_writebool
_appendbool
_truncatebool
_createbool
_create_newbool
Methods
new : (OpenOptions) fn() -> OpenOptions

All flags off. At least one of read/write/append must be set before to_flags() will accept it.

Returns: OpenOptions

read : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Read an entire file into a byte list (ArrayList(u8)).

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

write : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Write bytes to a file, creating or truncating it.

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

append : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Every write goes to the END of the file regardless of the seek position (O_APPEND). Grants write access on its own.

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

truncate : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Truncate the file to zero length on open. Needs write access.

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

create : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Create the file if it does not exist. Needs write or append access.

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

create_new : (OpenOptions) fn(self : OpenOptions, on : bool) -> OpenOptions

Create the file, failing if it ALREADY exists. Implies create, and the check-and-create is atomic (O_EXCL), which is what makes it usable as a lock.

Parameters

NameTypeNotes
selfOpenOptions
onbool

Returns: OpenOptions

creates : (OpenOptions) fn(self : OpenOptions) -> bool

True when this combination can create the file, so the caller knows whether the permission argument is consulted.

Parameters

NameTypeNotes
selfOpenOptions

Returns: bool

to_flags : (OpenOptions) fn(self : OpenOptions) -> Result(i32, String)

The POSIX flag set, or .Err naming the contradiction.

The rejected combinations are the ones POSIX does NOT diagnose — it quietly ignores whichever flag does not apply, handing back a file that behaves differently from what was asked:

  • nothing to do: no read, write or append.
  • truncate without write access: O_TRUNC with O_RDONLY is undefined by POSIX and a no-op on Linux.
  • truncate with append: contradictory — append means every write goes to the end, truncate means the end is zero.
  • create without write access: there is nothing to create the file for.

Parameters

NameTypeNotes
selfOpenOptions

Returns: Result(i32, String)

FilePermission newtype
FilePermission

POSIX file permission bits.

Fields

NameTypeDescription
modeu32
Methods
default : (FilePermission) fn() -> FilePermission

0o644rw-r--r--. The usual mode for a data file: writable by its owner, readable by everyone. This is what File.open passes when the mode creates a file and the caller named no permission; the process umask still clears bits from it, so a umask of 0o022 is what makes this the effective default rather than the request.

Returns: FilePermission

executable : (FilePermission) fn() -> FilePermission

0o755rwxr-xr-x. default plus the execute bit for everyone: scripts and binaries. Note the execute bit is only meaningful on POSIX; Windows decides executability from the file extension.

Returns: FilePermission

readonly : (FilePermission) fn() -> FilePermission

0o444r--r--r--. Readable by everyone, writable by nobody, which is the state Metadata.is_readonly reports true for. It does not stop root, and it does not stop the file's owner from chmod-ing it back.

Returns: FilePermission

private : (FilePermission) fn() -> FilePermission

0o600rw-------. Owner only: the mode to use for anything holding a credential, and the mode mkstemp (so TempFile) already creates with. Unlike the other three this is not weakened by a typical umask, because no group or other bit is being asked for.

Returns: FilePermission

SeekFrom enum
SeekFrom

Reference point for file seek operations.

Variants

VariantFieldsDescription
Start

Seek from the beginning of the file.

Current

Seek relative to the current position.

End

Seek relative to the end of the file.

Functions

read_to_string function
fn(path : Path, io : Io) -> Impl(Future(String, IoExn))

Read an entire file into a String.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(String, IoExn))

fn(path : str, io : Io) -> Impl(Future(String, IoExn))

Read an entire file into a String (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(String, IoExn))

fn(path : *u8, io : Io) -> Impl(Future(String, IoExn))

Read an entire file into a String (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(String, IoExn))

read function
fn(path : Path, io : Io) -> Impl(Future(ArrayList(u8), IoExn))

Read an entire file into a byte list (ArrayList(u8)).

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(ArrayList(u8), IoExn))

read_str function
fn(path : str, io : Io) -> Impl(Future(ArrayList(u8), IoExn))

Read an entire file into bytes (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(ArrayList(u8), IoExn))

read_cstr function
fn(path : *u8, io : Io) -> Impl(Future(ArrayList(u8), IoExn))

Read an entire file into bytes (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(ArrayList(u8), IoExn))

write_string function
fn(path : Path, data : String, io : Io) -> Impl(Future(unit, IoExn))

Write a String to a file, creating or truncating it.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

dataString
ioIo

Returns: Impl(Future(unit, IoExn))

write_string_str function
fn(path : str, data : str, io : Io) -> Impl(Future(unit, IoExn))

Write a str to a file, creating or truncating it (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

datastr
ioIo

Returns: Impl(Future(unit, IoExn))

fn(path : *u8, data : str, io : Io) -> Impl(Future(unit, IoExn))

Write a str to a file, creating or truncating it (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

datastr
ioIo

Returns: Impl(Future(unit, IoExn))

write function
fn(path : Path, data : ArrayList(u8), io : Io) -> Impl(Future(unit, IoExn))

Write bytes to a file, creating or truncating it.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

dataArrayList(u8)
ioIo

Returns: Impl(Future(unit, IoExn))

append_file function
fn(path : Path, data : String, io : Io) -> Impl(Future(unit, IoExn))

Append a String to a file, creating it if it does not exist.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

dataString
ioIo

Returns: Impl(Future(unit, IoExn))

append_file_str function
fn(path : str, data : str, io : Io) -> Impl(Future(unit, IoExn))

Append a str to a file (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

datastr
ioIo

Returns: Impl(Future(unit, IoExn))

exists_str function
fn(path : str, io : Io) -> Impl(Future(bool, Io))

Check if a path exists (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

exists_cstr function
fn(path : *u8, io : Io) -> Impl(Future(bool, Io))

Check if a path exists (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_file function
fn(path : Path, io : Io) -> Impl(Future(bool, Io))

Check if a path is a regular file. Returns false for any error.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_file_str function
fn(path : str, io : Io) -> Impl(Future(bool, Io))

Check if a path is a regular file (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_file_cstr function
fn(path : *u8, io : Io) -> Impl(Future(bool, Io))

Check if a path is a regular file (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_dir function
fn(path : Path, io : Io) -> Impl(Future(bool, Io))

Check if a path is a directory. Returns false for any error.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_dir_str function
fn(path : str, io : Io) -> Impl(Future(bool, Io))

Check if a path is a directory (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

is_dir_cstr function
fn(path : *u8, io : Io) -> Impl(Future(bool, Io))

Check if a path is a directory (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, Io))

canonicalize function
fn(path : Path, io : Io) -> Impl(Future(Path, IoExn))

Resolve a path to its canonical absolute form (resolves symlinks, . and ..). Throws if the path does not exist.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(Path, IoExn))

canonicalize_str function
fn(path : str, io : Io) -> Impl(Future(Path, IoExn))

Resolve a path to its canonical absolute form (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(Path, IoExn))

fn(path : *u8, io : Io) -> Impl(Future(Path, IoExn))

Resolve a path to its canonical absolute form (C string path variant).

Parameters

NameTypeNotesDescription
path*u8

Get the path this file was opened with.

ioIo

Returns: Impl(Future(Path, IoExn))

try_exists function
fn(path : Path, io : Io) -> Impl(Future(bool, IoExn))

Check if a path exists, PROPAGATING errors (std::fs::try_exists): .false only for a definitive not-there answer (ENOENT/ENOTDIR); a permission failure or any other error THROWS instead of masquerading as absence — the honest form exists cannot give (plans/archive/STD_API_AUDIT.md §7 P0).

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, IoExn))

try_exists_str function
fn(path : str, io : Io) -> Impl(Future(bool, IoExn))

try_exists (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

ioIo

Returns: Impl(Future(bool, IoExn))

set_permissions function
fn(path : Path, perm : FilePermission, io : Io) -> Impl(Future(unit, IoExn))

Set a path's POSIX permission bits.

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

permFilePermission
ioIo

Returns: Impl(Future(unit, IoExn))

fn(path : str, perm : FilePermission, io : Io) -> Impl(Future(unit, IoExn))

set_permissions (str path variant).

Parameters

NameTypeNotesDescription
pathstr

Get the path this file was opened with.

permFilePermission
ioIo

Returns: Impl(Future(unit, IoExn))

copy function
fn(from : Path, to : Path, io : Io) -> Impl(Future(u64, IoExn))

Copy a file's CONTENTS and permission bits from from to to (std::fs::copy), resolving to the number of bytes copied. to is created or truncated.

Parameters

NameTypeNotes
fromPath
toPath
ioIo

Returns: Impl(Future(u64, IoExn))

copy_str function
fn(from : str, to : str, io : Io) -> Impl(Future(u64, IoExn))

copy (str path variant).

Parameters

NameTypeNotes
fromstr
tostr
ioIo

Returns: Impl(Future(u64, IoExn))

exists function
fn(path : Path, io : Io) -> Impl : (Future[Future](bool) Io : Io)

Parameters

NameTypeNotesDescription
pathPath

Get the path this file was opened with.

ioIo

Returns: Impl : (Future[Future](bool) Io : Io)