github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/app/lib/filesystem/fileloader.go (about) 1 // Package filesystem - Content managed by Project Forge, see [projectforge.md] for details. 2 package filesystem 3 4 import ( 5 "context" 6 7 "github.com/kyleu/dbaudit/app/util" 8 ) 9 10 type FileLoader interface { 11 Root() string 12 Clone() FileLoader 13 PeekFile(path string, maxSize int) ([]byte, error) 14 Size(path string) int 15 ReadFile(path string) ([]byte, error) 16 FileReader(fn string) (Reader, error) 17 CreateDirectory(path string) error 18 WriteFile(path string, content []byte, mode FileMode, overwrite bool) error 19 FileWriter(fn string, createIfNeeded bool, appendMode bool) (Writer, error) 20 CopyFile(src string, tgt string) error 21 CopyRecursive(src string, tgt string, ignore []string, logger util.Logger) error 22 Move(src string, tgt string) error 23 ListFiles(path string, ignore []string, logger util.Logger) FileInfos 24 ListFilesRecursive(path string, ignore []string, logger util.Logger) ([]string, error) 25 ListTree(cfg util.ValueMap, path string, ignore []string, logger util.Logger, tags ...string) (*Tree, error) 26 ListJSON(path string, ignore []string, trimExtension bool, logger util.Logger) []string 27 ListExtension(path string, ext string, ignore []string, trimExtension bool, logger util.Logger) []string 28 ListDirectories(path string, ignore []string, logger util.Logger) []string 29 Walk(path string, ign []string, fn func(fp string, info *FileInfo, err error) error) error 30 Stat(path string) (*FileInfo, error) 31 SetMode(path string, mode FileMode) error 32 Exists(path string) bool 33 IsDir(path string) bool 34 Remove(path string, logger util.Logger) error 35 RemoveRecursive(pt string, logger util.Logger) error 36 Download(ctx context.Context, url string, path string, overwrite bool, logger util.Logger) (int, error) 37 UnzipToDir(src string, dest string) (*util.OrderedMap[int64], error) 38 String() string 39 }