Skip to content

Commit 0cf5fc1

Browse files
committed
*: fix os.PathSeparator in windows
1 parent 496b428 commit 0cf5fc1

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

memfs/memory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"gopkg.in/src-d/go-billy.v2"
1313
)
1414

15-
const separator = '/'
15+
const separator = filepath.Separator
1616

1717
// Memory a very convenient filesystem based on memory files
1818
type Memory struct {

osfs/os.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package osfs // import "gopkg.in/src-d/go-billy.v2/osfs"
44
import (
55
"io/ioutil"
66
"os"
7-
"path"
87
"path/filepath"
98

109
"gopkg.in/src-d/go-billy.v2"
@@ -36,7 +35,7 @@ func (fs *OS) Create(filename string) (billy.File, error) {
3635
// OpenFile is equivalent to standard os.OpenFile.
3736
// If flag os.O_CREATE is set, all parent directories will be created.
3837
func (fs *OS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error) {
39-
fullpath := path.Join(fs.base, filename)
38+
fullpath := fs.Join(fs.base, filename)
4039

4140
if flag&os.O_CREATE != 0 {
4241
if err := fs.createDir(fullpath); err != nil {
@@ -70,8 +69,8 @@ func (fs *OS) createDir(fullpath string) error {
7069

7170
// ReadDir returns the filesystem info for all the archives under the specified
7271
// path.
73-
func (ofs *OS) ReadDir(path string) ([]billy.FileInfo, error) {
74-
fullpath := ofs.Join(ofs.base, path)
72+
func (fs *OS) ReadDir(path string) ([]billy.FileInfo, error) {
73+
fullpath := fs.Join(fs.base, path)
7574

7675
l, err := ioutil.ReadDir(fullpath)
7776
if err != nil {

osfs/os_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (s *OSSuite) SetUpTest(c *C) {
2323
s.path, _ = ioutil.TempDir(os.TempDir(), "go-git-os-fs-test")
2424
s.FilesystemSuite.FS = New(s.path)
2525
}
26+
2627
func (s *OSSuite) TearDownTest(c *C) {
2728
err := os.RemoveAll(s.path)
2829
c.Assert(err, IsNil)
@@ -31,6 +32,7 @@ func (s *OSSuite) TearDownTest(c *C) {
3132
func (s *OSSuite) TestOpenDoesNotCreateDir(c *C) {
3233
_, err := s.FS.Open("dir/non-existent")
3334
c.Assert(err, NotNil)
35+
3436
_, err = os.Stat(filepath.Join(s.path, "dir"))
3537
c.Assert(os.IsNotExist(err), Equals, true)
3638
}

0 commit comments

Comments
 (0)