NewFileSystem

geesefs-0-30-9
Aaron Jacobs 2015-03-20 11:21:38 +11:00
parent 2fe7597c4e
commit e1375f33da
2 changed files with 22 additions and 3 deletions

View File

@ -14,7 +14,10 @@
package flushfs
import "github.com/jacobsa/fuse"
import (
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
)
// Create a file system containing a single file named "foo".
//
@ -23,4 +26,11 @@ import "github.com/jacobsa/fuse"
// called with the current contents of the file.
func NewFileSystem(
reportFlush func(string),
reportFsync func(string)) (fs fuse.FileSystem, err error)
reportFsync func(string)) (fs fuse.FileSystem, err error) {
fs = &flushFS{}
return
}
type flushFS struct {
fuseutil.NotImplementedFileSystem
}

View File

@ -44,6 +44,8 @@ type FlushFSTest struct {
func init() { RegisterTestSuite(&FlushFSTest{}) }
func (t *FlushFSTest) SetUp(ti *TestInfo) {
var err error
// Set up a file system.
reportTo := func(slice *[]string) func(string) {
return func(s string) {
@ -53,9 +55,16 @@ func (t *FlushFSTest) SetUp(ti *TestInfo) {
}
}
t.FileSystem = flushfs.NewFileSystem(
t.FileSystem, err = flushfs.NewFileSystem(
reportTo(&t.flushes),
reportTo(&t.fsyncs))
if err != nil {
panic(err)
}
// Mount it.
t.SampleTest.SetUp(ti)
}
////////////////////////////////////////////////////////////////////////