fs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fs provides write file system interfaces and related functions that are not part of the regular Go standard library.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDir = errors.New("parent is not a directory")

Functions

func MkdirAll

func MkdirAll(fsys CreateFS, name string, perm fs.FileMode) error

MkdirAll will ensure that a directory exists with the given name, creating all parent directories as needed. Returns an error on failure.

func WriteFile

func WriteFile(fsys CreateFS, name string, data []byte, perm fs.FileMode) error

WriteFile writes out a complete file, creating or updating the file in place using the given bytes. The file mode will be set as given as well. Returns an error on failure.

Types

type CreateFS

type CreateFS interface {
	fs.FS

	Create(name string) (FileWriter, error)    // create or append to a file
	Chmod(name string, mode fs.FileMode) error // change the mode of the file
	Mkdir(name string, perm fs.FileMode) error // create a directory
}

CreateFS is a file system that can create files.

type FileWriter

type FileWriter interface {
	Chmod(fs.FileMode) error   // change the file mode of the file
	Write([]byte) (int, error) // write data to the file
	Close() error              // close the file for writing
}

FileWriter is a writable file.

type ReaderFS

type ReaderFS interface {
	fs.GlobFS
	fs.ReadDirFS
	fs.ReadFileFS
	fs.StatFS
}

ReaderFS combines all the reader file system interfaces into a single interface for convenience.

type ReaderWriterFS

type ReaderWriterFS interface {
	ReaderFS
	WriterFS
}

ReaderWriterFS combines all the reader and writer file system interfaces into a single interface for convenience.

type WriteFileFS

type WriteFileFS interface {
	CreateFS

	// WriteFile writes out a complete file, creating or updating the file in
	// place using the given bytes. The file mode will be set as given as well.
	// Returns an error on failure.
	WriteFile(name string, data []byte, perm fs.FileMode) error
}

WriteFileFS is a file system that can write files whole.

type WriterFS

type WriterFS interface {
	WriteFileFS
}

WriterFS combines the file system writer interfaces into a single interface for convenience.

Jump to

Keyboard shortcuts

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