Skip to content
FutureBlitz

    Install

    Import std.io.vfs

    std.io.vfs

    std.io's virtual file system: a Vfs mounts folders, embedded folders, zips, and a program's own sources at points in one tree of its own, and reads them through the same calls as files. Its paths are its own, with '/' between names, on every OS; a later mount over the same place comes first, so a mod's folder can stand in for some of a game's embedded files.

    std/io/vfs.fb

    Types

    VfsSource interface

    Public Interface VfsSource

    Where a Vfs's files come from. Its paths are inside it, with '/' between names, and "" for its root, which is always a folder. What can't be read is an IOError; what isn't there is Null.

    std/io/vfs.fb, line 17

    • Method Read(path: String): UInt8[]? Throws IOError method #

      The bytes of the file at path, or Null when there's no file there.

    • Method KindAt(path: String): FileKind? Throws IOError method #

      What's at path, or Null when nothing is.

    • Method List(path: String): (String, FileKind)[]? Throws IOError method #

      The names of what's in the folder at path, and their kinds, in any order, or Null when there's no folder there.

    FolderSource class

    Public Final Class FolderSource Implements VfsSource

    A folder on the disk as a source, which reads it as it's asked, so it sees what changes in it. Nothing outside the folder is in it: by Windows' rules, a name with a ':' in it, which would be a drive or a file's stream, isn't there. Its root is a folder, empty while the folder isn't there or is a file. It's Final, so a Vfs's Async reads of it read what its Read does; a source that changes what a folder's files read as wraps one.

    std/io/vfs.fb, line 34

    • Public ReadOnly Field Folder: Path field #

      The folder on the disk it reads.

    • Public New(folder: Path) constructor #

      A FolderSource of folder.

    • Public Method Read(path: String): UInt8[]? Throws IOError method #

      The bytes of the file at path, or Null when there's no file there.

      Doc from std.io.vfs.VfsSource.Read.

    • Public Method KindAt(path: String): FileKind? Throws IOError method #

      What's at path, or Null when nothing is.

      Doc from std.io.vfs.VfsSource.KindAt.

    • Public Method List(path: String): (String, FileKind)[]? Throws IOError method #

      The names of what's in the folder at path, and their kinds, in any order, or Null when there's no folder there.

      Doc from std.io.vfs.VfsSource.List.

    EmbeddedSource class

    Public Class EmbeddedSource Implements VfsSource

    Files a program has in memory as a source, by their paths, like what EmbedFolder gives: each key is a file's path, with '/' (or '') between folders, and the folders are the ones the paths go through. It keeps the arrays it's given, and a read gives a copy of a file's bytes.

    std/io/vfs.fb, line 93

    • @PanicsAtCaller Public New(files: Map<String, UInt8[]>) constructor #

      Panics for a path that isn't a file's, one that goes above the root or has no names once its "."s and ".."s are taken out, like "", ".", or "a/..", and for paths that make one place a file and a folder too.

    • Public Method Read(path: String): UInt8[]? Throws IOError method #

      The bytes of the file at path, or Null when there's no file there.

      Doc from std.io.vfs.VfsSource.Read.

    • Public Method KindAt(path: String): FileKind? Throws IOError method #

      What's at path, or Null when nothing is.

      Doc from std.io.vfs.VfsSource.KindAt.

    • Public Method List(path: String): (String, FileKind)[]? Throws IOError method #

      The names of what's in the folder at path, and their kinds, in any order, or Null when there's no folder there.

      Doc from std.io.vfs.VfsSource.List.

    Vfs class

    Public Class Vfs

    A tree of mounted sources, read as files are. A file is the one of the last mount that has it; a folder lists what each mount has in it, and the mounts under it.

    std/io/vfs.fb, line 160

    • Public New() constructor #

      A new Vfs, with nothing mounted.

    • @PanicsAtCaller Public Method Mount(at: Path, source: VfsSource) method #

      Puts the source at at, a path in the Vfs, "" or "/" for its root, before what's mounted already. Panics for a path that goes above the root.

    • @PanicsAtCaller Public Method MountFolder(at: Path, folder: Path) method #

      Mounts a folder on the disk at at.

    • @PanicsAtCaller Public Method MountEmbedded(at: Path, files: Map<String, UInt8[]>) method #

      Mounts files in memory, like what EmbedFolder gives, at at.

    • Public Method Unmount(at: Path): Bool method #

      Takes out the last mount at at, and gives whether there was one.

    • Public Method ReadBytes(path: Path): UInt8[] Throws IOError method #

      The bytes of the file at path. One that no mount has throws an IOError of NOT_FOUND, a folder one of IS_A_DIRECTORY, and a path above the root one of INVALID_PATH.

    • Public Async Method ReadBytesAsync(path: Path): UInt8[] Throws IOError method #

      ReadBytes's Async twin, which reads a folder's files without blocking the main thread. It reads the mounts there were when it began, whatever's mounted while it waits.

    • Public Method ReadText(path: Path): String Throws IOError method #

      The file's bytes as text, with U+FFFD for each one that doesn't start well-formed UTF-8.

    • Public Async Method ReadTextAsync(path: Path): String Throws IOError method #

      What ReadText does, without blocking its thread: a call gives its Task.

    • Public Method ReadLines(path: Path): String[] Throws IOError method #

      The file's text in lines, split at "\n" and "\r\n", as File.ReadLines splits them.

    • Public Async Method ReadLinesAsync(path: Path): String[] Throws IOError method #

      What ReadLines does, without blocking its thread: a call gives its Task.

    • Public Method KindOf(path: Path): FileKind? Throws IOError method #

      What's at path: a file or a folder some mount has, or a folder a mount is in or at, or Null. What two mounts have is the last one's, as Entries finds it.

    • Public Method Exists(path: Path): Bool method #

      Whether there's a file at path, as KindOf finds it; an error is False.

    • Public Method DirExists(path: Path): Bool method #

      Whether there's a folder at path, as KindOf finds it; an error is False.

    • Public Method Entries(): DirEntry[] Throws IOError method #

      What's in the Vfs's root.

    • Public Method Entries(path: Path): DirEntry[] Throws IOError method #

      What's in the folder at path, from every mount that has it, and the mounts in it, in the order of their names' bytes. A name two mounts have is the last one's. A folder no mount has throws an IOError of NOT_FOUND, a file one of NOT_A_DIRECTORY, and a path above the root one of INVALID_PATH.

    • Public Method Walk(): DirEntry[] Throws IOError method #

      What's in the Vfs, all the way down, each folder before what's in it.

    • Public Method Walk(path: Path): DirEntry[] Throws IOError method #

      What's in the folder at path and in each folder in it, all the way down, each folder before what's in it, and each folder's entries in the order of their names' bytes. It throws as Entries does.

    • Public Method Glob(path: Path, pattern: String): DirEntry[] Throws IOError method #

      What's in the folder at path, and in the folders in it, whose path from it matches pattern, as Dir.Glob's patterns match, with '/' or '' between its names on every OS, as between a Vfs path's. It throws as Entries does.

    Report an issue with this page or with FutureBlitz on GitHub.