filesystem

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filesystem provides concise data structures for filesystem operations and functions to apply them to local files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir string

A Dir is a filesystem path to a directory from which to apply operations.

func (Dir) Apply

func (dir Dir) Apply(ops ...Operation) error

Apply applies the sequence of filesystem operations given. It stops at the first operation to fail.

func (Dir) Exists

func (dir Dir) Exists(path string) (bool, error)

Exists tests the existence of the given relative slash-separated path. The path is interpreted relative to dir.

func (Dir) FromSlash

func (dir Dir) FromSlash(path string) string

FromSlash resolves the given slash-separated path relative to dir. path must not be an absolute path.

func (Dir) ReadFile

func (dir Dir) ReadFile(path string) (string, error)

ReadFile reads the content of the given slash-separated path relative to dir.

func (Dir) String

func (dir Dir) String() string

String returns the directory path.

type Operation

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

An Operation describes a single step of a Dir.Apply. The zero value is a no-op.

func Mkdir

func Mkdir(name string) Operation

Mkdir returns a new make directory operation. The name is a slash-separated path relative to the Dir.

func Remove

func Remove(name string) Operation

Remove returns a new remove operation. The name is a slash-separated path relative to the Dir. Remove operations on directories are recursive.

func Rename

func Rename(old, new string) Operation

Rename returns a new rename operation. old and new are slash-separated paths relative to the Dir.

func Symlink(old, new string) Operation

Symlink returns a new symlink operation. new is a slash-separated path relative to the Dir. old is a slash-separated path relative to new.

func Write

func Write(name, content string) Operation

Write returns a new write operation. The name is a slash-separated path relative to the Dir.

func (Operation) String

func (o Operation) String() string

String returns a readable description of an operation like "remove foo/bar".

Jump to

Keyboard shortcuts

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