fs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package fs provides filesystem abstractions for asimonim.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem interface {
	// File operations
	WriteFile(name string, data []byte, perm fs.FileMode) error
	ReadFile(name string) ([]byte, error)
	Remove(name string) error

	// Directory operations
	MkdirAll(path string, perm fs.FileMode) error
	ReadDir(name string) ([]fs.DirEntry, error)
	TempDir() string

	// File system queries
	Stat(name string) (fs.FileInfo, error)
	Exists(path string) bool

	// fs.FS compatibility - allows use with fs.WalkDir
	Open(name string) (fs.File, error)
}

FileSystem provides an abstraction over filesystem operations. This interface is congruent with bennypowers.dev/cem/internal/platform.FileSystem and bennypowers.dev/mappa/fs.FileSystem to enable duck typing compatibility.

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem implements FileSystem using the standard os package.

func NewOSFileSystem

func NewOSFileSystem() *OSFileSystem

NewOSFileSystem creates a new filesystem that uses the standard os package.

func (*OSFileSystem) Exists

func (f *OSFileSystem) Exists(path string) bool

Exists returns true if the path exists.

func (*OSFileSystem) MkdirAll

func (f *OSFileSystem) MkdirAll(path string, perm fs.FileMode) error

MkdirAll creates a directory path and all parents that do not exist.

func (*OSFileSystem) Open

func (f *OSFileSystem) Open(name string) (fs.File, error)

Open opens the named file for reading.

func (*OSFileSystem) ReadDir

func (f *OSFileSystem) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the named directory and returns its entries.

func (*OSFileSystem) ReadFile

func (f *OSFileSystem) ReadFile(name string) ([]byte, error)

ReadFile reads the entire contents of a file.

func (*OSFileSystem) Remove

func (f *OSFileSystem) Remove(name string) error

Remove deletes the named file or empty directory.

func (*OSFileSystem) Stat

func (f *OSFileSystem) Stat(name string) (fs.FileInfo, error)

Stat returns file information for the named file.

func (*OSFileSystem) TempDir

func (f *OSFileSystem) TempDir() string

TempDir returns the default directory for temporary files.

func (*OSFileSystem) WriteFile

func (f *OSFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error

WriteFile writes data to a file with the given permissions.

Jump to

Keyboard shortcuts

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