Documentation ¶
Overview ¶
Package localfs has suppliers using the local filesystem.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystem ¶
type FileSystem struct { // RootPath is an optional parameter to jail the file system access for file access. RootPath string }
FileSystem provides local file system access through the filesystem.FileSystem interface.
Example ¶
package main import ( "fmt" "github.com/adamluzsi/frameless/ports/filesystem" "io" "io/fs" "os" "path/filepath" "github.com/adamluzsi/frameless/adapters/localfs" ) func main() { fsys := localfs.FileSystem{} file, err := fsys.OpenFile("test", os.O_RDWR|os.O_CREATE|os.O_EXCL, filesystem.ModeUserRWX) if err != nil { panic(err) } defer file.Close() file.Write([]byte("Hello world!")) file.Seek(0, io.SeekStart) bs, err := io.ReadAll(file) if err != nil { panic(err) } fmt.Println(string(bs)) // "Hello world!" file.Close() fsys.Remove("test") fsys.Mkdir("a", filesystem.ModeUserRWX) file2Name := filepath.Join("a", "test.txt") file2, err := filesystem.Create(fsys, file2Name) if err != nil { panic(err) } file2.Close() file2, err = filesystem.Open(fsys, file2Name) if err != nil { panic(err) } file2.Close() filesystem.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { return fs.SkipDir }) }
Output:
func (FileSystem) OpenFile ¶
func (fs FileSystem) OpenFile(name string, flag int, perm fs.FileMode) (filesystem.File, error)
func (FileSystem) Remove ¶
func (fs FileSystem) Remove(name string) error
Click to show internal directories.
Click to hide internal directories.