49 lines
897 B
Go
49 lines
897 B
Go
// Copyright (C) 2022 Marius Schellenberger
|
|
|
|
package provider
|
|
|
|
import (
|
|
"errors"
|
|
"io/fs"
|
|
"os"
|
|
)
|
|
|
|
var ErrFstat = errors.New("fstat not supported")
|
|
|
|
type FS interface {
|
|
Stat(string) (fs.FileInfo, error)
|
|
Remove(string) error
|
|
Open(string) (File, error)
|
|
OpenFile(string, int, os.FileMode) (File, error)
|
|
MkdirAll(string, os.FileMode) error
|
|
Root() string
|
|
Fstat(uintptr) (int64, error)
|
|
Close() error
|
|
}
|
|
|
|
type walk struct {
|
|
fs FS
|
|
}
|
|
|
|
func (w *walk) Open(p string) (fs.File, error) {
|
|
return w.fs.Open(p)
|
|
}
|
|
|
|
func WalkFS(fs FS) fs.FS {
|
|
return &walk{fs}
|
|
}
|
|
|
|
type File interface {
|
|
Name() string
|
|
Stat() (fs.FileInfo, error)
|
|
Truncate(int64) error
|
|
Sync() error
|
|
Fd() uintptr
|
|
ReadDir(int) ([]fs.DirEntry, error)
|
|
Read([]byte) (int, error)
|
|
ReadAt([]byte, int64) (int, error)
|
|
WriteAt([]byte, int64) (int, error)
|
|
Seek(int64, int) (int64, error)
|
|
Readdir(int) ([]fs.FileInfo, error)
|
|
Close() error
|
|
}
|