Stof Docs
Star on GitHubStof WebsiteDiscordContact Us
  • 🚀Welcome
  • â„šī¸Resources & Information
  • Book
    • Data Interface
    • Introduction & Design
    • Host Environments
      • Rust
      • TypeScript
        • Extend Stof
        • Import Statement
    • Data Interchange
      • JSON to Stof
      • Importing and Parsing Data
      • Exporting Data
      • REST and Restructure
    • Configuration Files
    • Schemas
      • Renaming Fields
      • Removing Fields
      • Validation & Transformation
        • Example Access
      • Nested Schemas
    • Orchestration
  • Common Concepts
    • Objects
    • Primitive Types
    • Functions
    • Fields
    • Object Types
    • Imports
    • Error Handling
    • Units
    • Casting/Conversions
  • Reference
    • CLI
      • 🏃Run
      • đŸ§ĒTest
      • 📚CLI Libraries
        • Filesystem Library
        • Time Library
        • HTTP Library
    • Stof Language
    • Libraries
      • Standard Library
      • Array/Vector Library
      • Number Library
      • String Library
      • Object Library
      • Function Library
      • Set Library
      • Map Library
      • Data Library
      • Tuple Library
      • Blob Library
      • Boolean Library
    • đŸĒ§Formats
Powered by GitBook
On this page
  • fs.write(path: str, contents: str): void
  • fs.write_blob(path: str, contents: blob): void
  • fs.read(path: str): str
  • fs.read_blob(path: str): blob

Was this helpful?

  1. Reference
  2. CLI
  3. CLI Libraries

Filesystem Library

Stof filesystem library ("fs").

PreviousCLI LibrariesNextTime Library

Last updated 3 months ago

Was this helpful?

The filesystem library is a part of Stof, however, is separately organized because it is system-dependent and cannot (and should not) be broadly implemented for all embedded environments.

All Stof filesystem calls go through this library though, so if this library is replicated or added in other environments, those features of Stof will work (primarily import statements). For example, in TypeScript, server environments (like Deno or Node.js) have filesystem calls that can be used to give Stof access to filesystem resources, but must do so explicitly (Stof is meant to be in the dark by default).

fs.write(path: str, contents: str): void

Will create a text file at the given path with the provided contents if it does not exist and will entirely replace its contents if it does.

fs.write_blob(path: str, contents: blob): void

Will create a binary file at the given path with the provided blob content if it does not exist and will entirely replace its contents if it does.

fs.read(path: str): str

Reads a text file into a string. Will throw an error if the file does not exist.

Used in implementations to read text files (up to the format to decide). Implementing this library function will enable Stof to import files of any format that uses it.

For anyone implementing a custom format, the helper function "fs_read_string" exists on the Rust Stof document to make this easy, ensuring other embedded environments have access.

fs.read_blob(path: str): blob

Reads a binary file into a blob. Will throw an error if the file does not exist.

Used in implementations to read binary files (up to the format to decide). Implementing this library function will enable Stof to import files of any format that uses it.

For anyone implementing a custom format, the helper function "fs_read_blob" exists on the Rust Stof document to make this easy, ensuring other embedded environments have access.

📚
format
format