From 03c0cb57021caedd556f37042eef4ca96c8bac5a Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Tue, 15 Dec 2015 18:17:36 +0100 Subject: [PATCH] drop filter_regexp for now, needs some more changes for reading dirs --- filter_regexp.go | 104 ----------------------------------------------- filter_test.go | 5 ++- 2 files changed, 3 insertions(+), 106 deletions(-) delete mode 100644 filter_regexp.go diff --git a/filter_regexp.go b/filter_regexp.go deleted file mode 100644 index b061563..0000000 --- a/filter_regexp.go +++ /dev/null @@ -1,104 +0,0 @@ -package afero - -import ( - "os" - "regexp" - "syscall" - "time" -) - -type RegexpFilter struct { - file *regexp.Regexp - dir *regexp.Regexp -} - -func NewRegexpFilter(file *regexp.Regexp, dir *regexp.Regexp) Fs { - return &RegexpFilter{file: file, dir: dir} -} - -func (r *RegexpFilter) Chtimes(n string, a, m time.Time) error { - if !r.file.MatchString(n) { - return syscall.ENOENT - } - return nil -} - -func (r *RegexpFilter) Chmod(n string, m os.FileMode) error { - if !r.file.MatchString(n) { - return syscall.ENOENT - } - return nil -} - -func (r *RegexpFilter) Name() string { - return "RegexpFilter" -} - -func (r *RegexpFilter) Stat(n string) (os.FileInfo, error) { - // FIXME - what about Stat() on dirs? - if !r.file.MatchString(n) { - return nil, syscall.ENOENT - } - return nil, nil -} - -func (r *RegexpFilter) Rename(o, n string) error { - // FIXME - what about renaming dirs? - switch { - case !r.file.MatchString(o): - return syscall.ENOENT - case !r.file.MatchString(n): - return syscall.EPERM - default: - return nil - } -} - -func (r *RegexpFilter) RemoveAll(p string) error { - if !r.dir.MatchString(p) { - return syscall.EPERM // FIXME ENOENT? - } - return nil -} - -func (r *RegexpFilter) Remove(n string) error { - if !r.file.MatchString(n) { - return syscall.ENOENT - } - return nil -} - -func (r *RegexpFilter) OpenFile(name string, flag int, perm os.FileMode) (File, error) { - if !r.file.MatchString(name) { - return nil, syscall.ENOENT - } - return nil, nil -} - -func (r *RegexpFilter) Open(n string) (File, error) { - if !r.file.MatchString(n) { - return nil, syscall.ENOENT - } - return nil, nil -} - -func (r *RegexpFilter) Mkdir(n string, p os.FileMode) error { - if !r.dir.MatchString(n) { - return syscall.EPERM - } - return nil -} - -func (r *RegexpFilter) MkdirAll(n string, p os.FileMode) error { - if !r.dir.MatchString(n) { - return syscall.EPERM - } - return nil -} - -func (r *RegexpFilter) Create(n string) (File, error) { - if !r.file.MatchString(n) { - return nil, syscall.EPERM - } - return nil, nil -} diff --git a/filter_test.go b/filter_test.go index d05a707..803fdb0 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,7 +1,7 @@ package afero import ( - "regexp" +// "regexp" "testing" ) @@ -52,7 +52,7 @@ func TestReadonlyRemoveAndRead(t *testing.T) { t.Errorf("File still present") } } - +/* func TestRegexp(t *testing.T) { mfs := &MemMapFs{} fs := NewFilter(mfs) @@ -75,3 +75,4 @@ func TestRORegexpChain(t *testing.T) { } t.Logf("ERR=%s", err) } +*/