Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyAllToDir ¶
CopyAllToDir copies all entries from src filesystem to destintation dir.
Example ¶
package main import ( "log" "os" "path/filepath" "github.com/b4fun/battery/fs" "github.com/b4fun/battery/fs/testdata" ) func main() { tempDir, err := os.MkdirTemp("", "battery-fs") if err != nil { log.Fatal(err) } defer os.RemoveAll(tempDir) err = fs.CopyAllToDir(testdata.Root, tempDir) if err != nil { log.Fatal(err) } walkErr := filepath.Walk(tempDir, func(path string, info os.FileInfo, err error) error { if err != nil { return err } log.Printf("%s %s", path, info.Mode()) return nil }) if walkErr != nil { log.Fatal(walkErr) } }
Output:
Types ¶
type WritableFS ¶
type WritableFS interface { // OpenFile opens the named file with specified flag. // TODO: define the behavior OpenFile(name string, flag int, perm os.FileMode) (WriteableFile, error) // MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. // TODO: define the behavior MkdirAll(path string, perm os.FileMode) error }
WritableFS provides a writeable FS interface for interacting with the file system. See: https://github.com/golang/go/issues/45757
type WriteableFile ¶
type WriteableFile interface { // Write writes len(b) bytes to the File. // It returns the number of bytes written and an error, if any. // Write returns a non-nil error when n != len(b). Write([]byte) (int, error) // Close closes the file. Close() error }
WriteableFile provides the write interface for a file.
Click to show internal directories.
Click to hide internal directories.