fs: Add interface and FS implementations

This adds two implementations of the new `FS` interface: One for the local
file system (`Local`) and one for a single file read from an
`io.Reader` (`Reader`).
This commit is contained in:
Alexander Neumann
2018-01-03 21:53:45 +01:00
parent 83ca08245b
commit c4b2486b7c
14 changed files with 994 additions and 14 deletions

31
internal/fs/stat_test.go Normal file
View File

@@ -0,0 +1,31 @@
package fs
import (
"io/ioutil"
"path/filepath"
"testing"
restictest "github.com/restic/restic/internal/test"
)
func TestExtendedStat(t *testing.T) {
tempdir, cleanup := restictest.TempDir(t)
defer cleanup()
filename := filepath.Join(tempdir, "file")
err := ioutil.WriteFile(filename, []byte("foobar"), 0640)
if err != nil {
t.Fatal(err)
}
fi, err := Lstat(filename)
if err != nil {
t.Fatal(err)
}
extFI := ExtendedStat(fi)
if !extFI.ModTime.Equal(fi.ModTime()) {
t.Errorf("extFI.ModTime does not match, want %v, got %v", fi.ModTime(), extFI.ModTime)
}
}