ltk

Module files

Source
Expand description

The user’s files, asynchronously and alike on every platform: natively through std::fs on a worker thread of ltk’s, in a browser through forge/web’s file requests (forge/web/DESIGN.md, section 11). Every operation hands its result to done, whose message reaches the app through its ChannelSender, so nothing blocks the app’s thread. Results come in no set order, so an app that may have moved on checks that a result is still the one it waits for.

Contents travel in chunks: a large file is read in ranges with read_range and written through a Writer, one chunk after the other is answered, CHUNK bytes at a time; read and write() are for small files. A copy runs where the files are, its contents never passing through the app.

Errors are io::Errors of the same kinds on every platform: NotFound, AlreadyExists, NotADirectory, IsADirectory, DirectoryNotEmpty, PermissionDenied, Unsupported, and Interrupted for a cancelled copy.

An app’s own resources are read through crate::vfs, not here.

Modules§

  • The operations of crate::files with a function in place of a message, for code with no run loop’s crate::ChannelSender to take one, such as a session daemon: done is called on ltk’s worker thread natively and on the page’s thread in a browser.

Structs§

  • One entry of a directory.
  • A folder of the user’s computer, mounted in a browser.
  • A copy in progress.
  • A file being written in chunks, whose contents appear only once closed; in a browser a new file shows empty until then. Dropped without Writer::close, it is aborted and the file left as it was.

Enums§

Constants§

  • The size of the chunks a large file is best read and written in.

Functions§

  • Copy the file from to to, which must not exist and appears only once whole. progress hears of the bytes copied out of the total every so often.
  • Copy the directory from and everything in it to to, which must not exist; a copy that fails or is cancelled leaves no to behind.
  • The entries of the directory path, in no order.
  • The MIME type shared-mime-info gives a file named name, from its globs alone.
  • Have the browser ask the user for a folder of their computer and mount it. Call it from the user’s press, since the browser opens its picker only then; natively it fails with Unsupported.
  • The folders mounted in a browser, as the desktop last said; None natively, where nothing is mounted, and before the desktop has said.
  • A Writer for the file at path.
  • The whole of a small file.
  • Up to length bytes of the file from offset; fewer at its end, none past it.
  • Remove a file or an empty directory.
  • Remove a file, or a directory and everything in it.
  • Move from to to, which must not exist; in a browser, within one mount.
  • Create or replace a small file with data, whole or not at all.