filesystem

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filesystem keeps files for the app. It's plain Go on top of the folders the system gives each app, so it needs no plugin add. Paths are relative to the folder, and can't leave it.

filesystem.Write(ctx, filesystem.Data, "orders/1042.json", b)
b, err := filesystem.Read(ctx, filesystem.Data, "orders/1042.json")
names, err := filesystem.List(ctx, filesystem.Data, "orders")

Under `nimbus native dev` the app runs on this machine, so the files live in the user cache directory instead of on the device.

Index

Constants

This section is empty.

Variables

View Source
var ErrOutside = errors.New("filesystem: path leaves its folder")

ErrOutside is a path that leaves its folder.

Functions

func Append

func Append(ctx context.Context, f Folder, name string, data []byte) error

Append adds to the end of a file, making it if needed.

func Delete

func Delete(ctx context.Context, f Folder, name string) error

Delete removes a file or folder. A missing one is fine.

func Exists

func Exists(ctx context.Context, f Folder, name string) (bool, error)

Exists reports whether a file is there.

func List

func List(ctx context.Context, f Folder, name string) ([]string, error)

List returns the names in a folder, sorted. A missing folder is empty.

func Path

func Path(ctx context.Context, f Folder, name string) (string, error)

Path is the file's full path, for what takes one: an upload, say.

func Read

func Read(ctx context.Context, f Folder, name string) ([]byte, error)

Read returns a file. A missing one is fs.ErrNotExist.

func Write

func Write(ctx context.Context, f Folder, name string, data []byte) error

Write replaces a file, making its folders. A crash partway leaves the old file whole.

Types

type Folder

type Folder int

Folder is where a file lives.

const (
	Data  Folder = iota // kept until the app is deleted
	Cache               // the system may clear it when space runs low
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL