file

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package file provides a local filesystem backend for omnistorage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFromConfig

func NewFromConfig(configMap map[string]string) (omnistorage.Backend, error)

NewFromConfig creates a new file backend from a config map. Supported keys:

  • root: root directory (default: ".")
  • create_dirs: "true" or "false" (default: "true")

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend implements omnistorage.Backend for local filesystem.

func New

func New(config Config) *Backend

New creates a new file backend with the given configuration.

func (*Backend) Close

func (b *Backend) Close() error

Close releases any resources held by the backend.

func (*Backend) Copy

func (b *Backend) Copy(ctx context.Context, src, dst string) error

Copy copies an object from src to dst using server-side copy (hard link or copy).

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, path string) error

Delete removes a path.

func (*Backend) Exists

func (b *Backend) Exists(ctx context.Context, path string) (bool, error)

Exists checks if a path exists.

func (*Backend) Features

func (b *Backend) Features() omnistorage.Features

Features returns the capabilities of the file backend.

func (*Backend) List

func (b *Backend) List(ctx context.Context, prefix string) ([]string, error)

List lists paths with the given prefix.

func (*Backend) Mkdir

func (b *Backend) Mkdir(ctx context.Context, path string) error

Mkdir creates a directory at the given path.

func (*Backend) Move

func (b *Backend) Move(ctx context.Context, src, dst string) error

Move moves/renames an object from src to dst.

func (*Backend) NewReader

func (b *Backend) NewReader(ctx context.Context, path string, opts ...omnistorage.ReaderOption) (io.ReadCloser, error)

NewReader creates a reader for the given path.

func (*Backend) NewWriter

func (b *Backend) NewWriter(ctx context.Context, path string, opts ...omnistorage.WriterOption) (io.WriteCloser, error)

NewWriter creates a writer for the given path.

func (*Backend) Rmdir

func (b *Backend) Rmdir(ctx context.Context, path string) error

Rmdir removes an empty directory at the given path.

func (*Backend) Stat

func (b *Backend) Stat(ctx context.Context, path string) (omnistorage.ObjectInfo, error)

Stat returns metadata about an object at the given path.

type Config

type Config struct {
	// Root is the root directory for all operations.
	// All paths are relative to this directory.
	Root string

	// CreateDirs controls whether parent directories are created automatically.
	// Default: true
	CreateDirs bool

	// DirPermissions is the permission mode for created directories.
	// Default: 0755
	DirPermissions os.FileMode

	// FilePermissions is the permission mode for created files.
	// Default: 0644
	FilePermissions os.FileMode
}

Config holds configuration for the file backend.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration.

Jump to

Keyboard shortcuts

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