Skip to content

Commit 529dad7

Browse files
committed
boundos: Remove redundant call to expandDot
Signed-off-by: Paulo Gomes <[email protected]>
1 parent c294666 commit 529dad7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

osfs/os_bound.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import (
3434
var (
3535
ErrBaseDirCannotBeRemoved = errors.New("base dir cannot be removed")
3636
ErrBaseDirCannotBeRenamed = errors.New("base dir cannot be renamed")
37+
38+
dotPrefixes = []string{"./", ".\\"}
3739
)
3840

3941
// BoundOS is a fs implementation based on the OS filesystem which is bound to
@@ -66,6 +68,7 @@ func (fs *BoundOS) OpenFile(filename string, flag int, perm fs.FileMode) (billy.
6668
if err != nil {
6769
return nil, err
6870
}
71+
6972
return openFile(fn, flag, perm, fs.createDir)
7073
}
7174

@@ -113,7 +116,6 @@ func (fs *BoundOS) MkdirAll(path string, perm fs.FileMode) error {
113116
}
114117

115118
func (fs *BoundOS) Open(filename string) (billy.File, error) {
116-
filename = fs.expandDot(filename)
117119
return fs.OpenFile(filename, os.O_RDONLY, 0)
118120
}
119121

@@ -187,7 +189,7 @@ func (fs *BoundOS) expandDot(p string) string {
187189
if p == "." {
188190
return fs.baseDir
189191
}
190-
for _, prefix := range []string{"./", ".\\"} {
192+
for _, prefix := range dotPrefixes {
191193
if strings.HasPrefix(p, prefix) {
192194
return filepath.Join(fs.baseDir, strings.TrimPrefix(p, prefix))
193195
}

0 commit comments

Comments
 (0)