Documentation ¶
Overview ¶
Package fs is built on top of the fs package of the go standard library.
Index ¶
- Variables
- func ApplyIf(m MutFS, op BinaryOp, src, dst string) (supports bool, err error)
- func Copy(m MutFS, src, dst string) (err error)
- func CreateAndUseFile(fsys FS, path string, user UseWriter) (err error)
- func EncodeToString(enc Encoding, src []byte) (s string)
- func ExecuteBinOp(mfs MutFS, def BinaryOpDef) error
- func ExecuteBinOps(fs FS, defs []BinaryOpDef) []error
- func MkDirAllPerm(mfs MutFS, path string, perm os.FileMode) (err error)
- func Mkdir(fsys fs.FS, path string, perm os.FileMode) error
- func ModeToType(mode fs.FileMode) (t path.Type)
- func Move(m MutFS, src, dst string) (err error)
- func MustMatch(mode fs.FileMode, t path.Type) (err error)
- func Open(fsys fs.FS, res Resource) (io.ReadCloser, error)
- func OpenAndUseFile(fsys FS, path string, user UseReader) (err error)
- func Validate(fsys FS, like path.Like) (err error)
- type BinaryOp
- type BinaryOpDef
- type BinaryOpError
- type BufReadCloser
- type BufWriteCloser
- type Buffer
- type BufferSizes
- type Encoding
- type EnsureType
- type FS
- type File
- type FileInfo
- type InOutFiles
- type Inputs
- type LogEncoding
- type Main
- type MkDirAllFS
- type MoveFs
- type MutFS
- type MutFile
- type MutOp
- type NoCloseReader
- type NoCloseWriter
- type OpError
- type OpenFunc
- type Operation
- type OsFS
- func (f OsFS) BinaryOp(op BinaryOp, src, dst string) (err error)
- func (OsFS) Create(name string) (f MutFile, err error)
- func (OsFS) Glob(name string) (matches []string, err error)
- func (OsFS) Mkdir(name string, perm os.FileMode) (err error)
- func (OsFS) MkdirAll(name string, perm os.FileMode) (err error)
- func (OsFS) Open(name string) (f fs.File, err error)
- func (OsFS) OpenMut(name string) (f MutFile, err error)
- func (OsFS) Remove(name string) (err error)
- func (OsFS) Rename(oldpath, newpath string) (err error)
- func (f OsFS) SupportsOp(op BinaryOp) (ok bool)
- type Path
- type Resource
- type ResourceID
- type ResourceKind
- type UnsupportedBinaryOpError
- type UseReader
- type UseWriter
- type ValidateFS
- type ValidatedFS
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EnsureFile = TypeEnsurer(path.TypeFile) EnsureDir = TypeEnsurer(path.TypeDirectory) )
View Source
var ErrNonMutFS = fmt.Errorf("fs/mut_fs.go: got a non a mutable filesystem (fs.MutFS)")
Functions ¶
func EncodeToString ¶
func ExecuteBinOp ¶
func ExecuteBinOp(mfs MutFS, def BinaryOpDef) error
func ExecuteBinOps ¶
func ExecuteBinOps(fs FS, defs []BinaryOpDef) []error
Types ¶
type BinaryOpDef ¶
type BinaryOpDef struct { File InOutFiles `json:"file"` Op BinaryOp `json:"op"` }
type BinaryOpError ¶
type BinaryOpError struct { // Binary operation that caused failure Op BinaryOp // The two arguments passed to the operation First, Second string // contains filtered or unexported fields }
func (BinaryOpError) Error ¶
func (b BinaryOpError) Error() (s string)
func (BinaryOpError) Unwrap ¶
func (b BinaryOpError) Unwrap() (err error)
type BufReadCloser ¶
type BufReadCloser struct {
// contains filtered or unexported fields
}
func (BufReadCloser) Close ¶
func (buf BufReadCloser) Close() error
type BufWriteCloser ¶
type BufWriteCloser struct {
// contains filtered or unexported fields
}
func (BufWriteCloser) Close ¶
func (buf BufWriteCloser) Close() error
type Buffer ¶
func (Buffer) ResourceKind ¶
func (Buffer) ResourceKind() ResourceKind
type BufferSizes ¶
func DefaultBufferSize ¶
func DefaultBufferSize() BufferSizes
type EnsureType ¶
type EnsureType struct {
// contains filtered or unexported fields
}
func TypeEnsurer ¶
func TypeEnsurer(pathType path.Type) (e EnsureType)
func (EnsureType) ValidatePath ¶
func (e EnsureType) ValidatePath(fsys FS, like string) (err error)
type InOutFiles ¶
type Inputs ¶
func (*Inputs) UnmarshalJSON ¶
type LogEncoding ¶
type LogEncoding struct {
// contains filtered or unexported fields
}
TODO: add logging
func NewLogEncoding ¶
func NewLogEncoding(encoding Encoding, log zerolog.Logger) (le LogEncoding)
func (LogEncoding) DecodedLen ¶
func (le LogEncoding) DecodedLen(n int) int
func (LogEncoding) Encode ¶
func (le LogEncoding) Encode(in, out []byte)
func (LogEncoding) EncodedLen ¶
func (le LogEncoding) EncodedLen(n int) int
type Main ¶
type MkDirAllFS ¶
MkDirAllFS is an extension interface to MutFS.
type MutFS ¶
type MutFS interface { fs.FS // OpenMut Opens file for writing and changing the file's permissions. OpenMut(name string) (MutFile, error) // Create creates an empty file. Create(name string) (MutFile, error) // Remove removes a file from the filesystem. Remove(name string) error // Mkdir creates directory at the specified path. Mkdir(name string, perm os.FileMode) error // BinaryOp carries out an operation with two arguments BinaryOp(op BinaryOp, src, dst string) error // SupportsOp determines wether the filesystem support a given operation SupportsOp(op BinaryOp) bool }
MutFS is the extended version of fs.FS that is capable of changing / mutating its structure.
type MutFile ¶
type NoCloseReader ¶
type NoCloseReader struct {
// contains filtered or unexported fields
}
func (NoCloseReader) Close ¶
func (NoCloseReader) Close() error
type NoCloseWriter ¶
type NoCloseWriter struct {
// contains filtered or unexported fields
}
func (NoCloseWriter) Close ¶
func (NoCloseWriter) Close() error
type OpError ¶
type OsFS ¶
type OsFS struct{}
OsFS represents a filesystem backed by the filesystem of the underlying OS.
func OS ¶
func OS() *OsFS
OS returns a filesystem backed by the filesystem of the os. It wraps os.* stdlib operations.
func (OsFS) SupportsOp ¶
type Path ¶
type Path struct {
Path string `json:"path"`
}
func (Path) ResourceKind ¶
func (Path) ResourceKind() ResourceKind
type Resource ¶
type Resource interface {
ResourceKind() ResourceKind
}
type ResourceID ¶
type ResourceID string
type ResourceKind ¶
type ResourceKind int
ENUM(
Path Buffer
)
const ( ResourcePath ResourceKind = iota ResourceBuffer )
type UnsupportedBinaryOpError ¶
type UnsupportedBinaryOpError struct {
Op BinaryOp
}
func (*UnsupportedBinaryOpError) Error ¶
func (e *UnsupportedBinaryOpError) Error() string
type ValidatedFS ¶
type ValidatedFS struct {
// contains filtered or unexported fields
}
func Validated ¶
func Validated(fsys FS, valid Validator) (v ValidatedFS)
func (ValidatedFS) Validate ¶
func (v ValidatedFS) Validate(like string) (err error)
Click to show internal directories.
Click to hide internal directories.