osfsrw

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

osfsrw

osfsrw is a wrapper for the local operating system's filesystem, implementing the writefs.FullFS interface.

Features

  • Read/Write Support: Fully supports all writefs write operations (Create, Append, MkDir, Rename, Remove, Copy, WriteFile).
  • Standard Library Interoperability: Implements fs.ReadDirFS, fs.ReadFileFS, fs.StatFS, and fs.SubFS.
  • Read-Only Mode: Can be initialized in a read-only mode where any write attempt will return an error.
  • Path Isolation: Paths are relative to a specified base directory.

Usage

import (
	"github.com/je4/filesystem/v3/pkg/osfsrw"
	"github.com/je4/utils/v2/pkg/zLogger"
)

// Initialize with a base directory
fsys, err := osfsrw.NewFS("/path/to/data", false, logger)
if err != nil {
	// handle error
}

// Write a file
bytesWritten, err := fsys.WriteFile("test.txt", []byte("Hello, OSFS!"))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateFSFunc

func NewCreateFSFunc(logger zLogger.ZLogger) writefs.CreateFSFunc

func NewFS

func NewFS(dir string, readOnly bool, logger zLogger.ZLogger) (*osFSRW, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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