fs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fs provides filesystem abstractions for reading files from local disk or git repos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	Name  string
	IsDir bool
}

DirEntry represents a single directory entry.

type FileInfo

type FileInfo struct {
	Name    string
	IsDir   bool
	Size    int64
	ModTime time.Time
}

FileInfo holds file metadata.

type FileSystem

type FileSystem interface {
	ReadFile(path string) ([]byte, error)
	Stat(path string) (FileInfo, error)
	ReadDir(path string) ([]DirEntry, error)
}

FileSystem abstracts file operations so callers can work with either the local filesystem or a git object database.

type GitFS

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

GitFS implements FileSystem by reading from a git ref (branch, tag, or commit).

func NewGitFS

func NewGitFS(repoPath, ref string) *GitFS

NewGitFS creates a GitFS that reads files from the given ref in the repository at repoPath.

func (*GitFS) ReadDir

func (g *GitFS) ReadDir(path string) ([]DirEntry, error)

ReadDir lists the immediate children of the directory at the given path in the git ref.

func (*GitFS) ReadFile

func (g *GitFS) ReadFile(path string) ([]byte, error)

ReadFile reads the contents of the file at the given path from the git ref.

func (*GitFS) Stat

func (g *GitFS) Stat(path string) (FileInfo, error)

Stat returns metadata for the file or directory at the given path in the git ref.

type LocalFS

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

LocalFS implements FileSystem using the local filesystem.

func NewLocalFS

func NewLocalFS(root string) *LocalFS

NewLocalFS creates a LocalFS rooted at the given directory.

func (*LocalFS) ReadDir

func (l *LocalFS) ReadDir(path string) ([]DirEntry, error)

ReadDir lists the immediate children of the directory at the given path relative to the root.

func (*LocalFS) ReadFile

func (l *LocalFS) ReadFile(path string) ([]byte, error)

ReadFile reads the contents of the file at the given path relative to the root.

func (*LocalFS) Stat

func (l *LocalFS) Stat(path string) (FileInfo, error)

Stat returns metadata for the file or directory at the given path relative to the root.

Jump to

Keyboard shortcuts

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