From e1375f33da2ce400e27b1bdcb6e32909dff3f5a9 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 20 Mar 2015 11:21:38 +1100 Subject: [PATCH] NewFileSystem --- samples/flushfs/flush_fs.go | 14 ++++++++++++-- samples/flushfs/flush_fs_test.go | 11 ++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/samples/flushfs/flush_fs.go b/samples/flushfs/flush_fs.go index ae5875c..4f48bc5 100644 --- a/samples/flushfs/flush_fs.go +++ b/samples/flushfs/flush_fs.go @@ -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 +} diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index aaa5998..694669f 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -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) } ////////////////////////////////////////////////////////////////////////