io library
The local file system: TomLocalFileSystem, with the platform parts it stands on — one watch per directory where the platform has no recursive watch, the freedesktop.org home trash, and the Windows Recycle Bin.
Uses dart:io and dart:ffi; a browser build takes
tom_file_system.dart alone.
Classes
- TomDirectoryWatches
- Watches root and the directories below it that descend admits, reporting the absolute path of every change on stream.
- TomFileChange
- A change under a watched root. Advisory: a watch may miss a change, and a caller that must know compares revisions.
- TomFileChangeEvent
- A create, write, rename or delete made through a TomFileSystem.
- TomFileContent
- A file's bytes and the revision they were read at.
- TomFileEntry
- One entry of a listed directory.
- TomFileRevision
- The version of a file as it was read: what a write is checked against.
- TomFileSystem
-
The contract. A file system has a root; a relative URI resolves against
it, and
paths in entries and changes are relative to it. - TomFileSystemBase
- A TomFileSystem whose implementation supplies the primitives — list, stat, read, write, create, rename, trash, delete, watch — and announces its own changes with emitChange.
- TomLocalFileSystem
- A local folder as a TomFileSystem.
- TomMemoryFileSystem
- Files and folders keyed by their absolute path. Writes are atomic by construction, revisions are checked like on disk, there is no trash, and watch reports every change made through it.
- TomWillSaveEvent
- Announced before a file is saved. A listener may change content, and the changed content is what is saved.
Enums
- TomFileChangeType
- How a file changed.
- TomFileEntryKind
- What an entry of a directory is.
- TomSaveReason
- Why a file is saved.
Functions
-
tomLooksLikeText(
List< int> head) → bool - The text test over a file's first bytes: a UTF-16 byte-order mark, or no NUL byte in the first 8 KiB and a valid UTF-8 prefix.
-
tomTrimToLineEnd(
String text) → String -
textwithout its last, partial line — a head slice's cut. -
tomTrimToLineStart(
String text) → String -
textwithout its first, partial line — a tail slice's cut. Text with no line break is returned whole: there is nothing to snap to. -
tomWindowsRecycle(
String absolute) → bool -
Moves
absolute— a file or a folder, a full Windows path — to the Recycle Bin. Answers whether it went there; nothing is asked of the user and no dialog is shown. -
tomXdgTrash(
String absolute, {Map< String, String> ? environment, DateTime? now}) → bool -
Moves
absoluteinto the home trash:$XDG_DATA_HOME/Trash, or~/.local/share/Trash. Answers false, with nothing changed, when there is no home to put a trash in or the item is on another filesystem than the trash — the specification gives such an item its mount's own trash, which only the desktop's tools know how to find.
Exceptions / Errors
- TomFileConflict
- A write refused because the file is no longer the revision it was read at — someone else changed it.
- TomFileSystemException
- Thrown for a path that is not there, or not the kind of entry asked for.