aboutsummaryrefslogtreecommitdiffstats
path: root/utils/fs
diff options
context:
space:
mode:
Diffstat (limited to 'utils/fs')
-rw-r--r--utils/fs/os/os.go2
-rw-r--r--utils/fs/os/os_test.go8
2 files changed, 9 insertions, 1 deletions
diff --git a/utils/fs/os/os.go b/utils/fs/os/os.go
index 3ff825e..4f4e651 100644
--- a/utils/fs/os/os.go
+++ b/utils/fs/os/os.go
@@ -32,7 +32,7 @@ func (fs *OS) Create(filename string) (fs.File, error) {
func (fs *OS) OpenFile(filename string, flag int, perm os.FileMode) (fs.File, error) {
fullpath := path.Join(fs.base, filename)
- if flag|os.O_CREATE != 0 {
+ if flag&os.O_CREATE != 0 {
if err := fs.createDir(fullpath); err != nil {
return nil, err
}
diff --git a/utils/fs/os/os_test.go b/utils/fs/os/os_test.go
index 756e284..2bb9391 100644
--- a/utils/fs/os/os_test.go
+++ b/utils/fs/os/os_test.go
@@ -3,6 +3,7 @@ package os_test
import (
"io/ioutil"
stdos "os"
+ "path/filepath"
"testing"
. "gopkg.in/check.v1"
@@ -27,3 +28,10 @@ func (s *OSSuite) TearDownTest(c *C) {
err := stdos.RemoveAll(s.path)
c.Assert(err, IsNil)
}
+
+func (s *OSSuite) TestOpenDoesNotCreateDir(c *C) {
+ _, err := s.Fs.Open("dir/non-existant")
+ c.Assert(err, NotNil)
+ _, err = stdos.Stat(filepath.Join(s.path, "dir"))
+ c.Assert(stdos.IsNotExist(err), Equals, true)
+}