implemented os file interface acstraction
This commit is contained in:
parent
23528fe28e
commit
ad41ddbe54
11 changed files with 223 additions and 92 deletions
45
pkg/provider/interface.go
Normal file
45
pkg/provider/interface.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (C) 2022 Marius Schellenberger
|
||||
|
||||
package provider
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue