Skip to content

Commit 5a830a3

Browse files
committed
Replace os.FileMode with fs.FileMode
Upstream the former is already pointing to the latter, so this should represent no actual change to downstream users. Signed-off-by: Paulo Gomes <[email protected]>
1 parent 0ffbf59 commit 5a830a3

File tree

14 files changed

+40
-33
lines changed

14 files changed

+40
-33
lines changed

fs.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"io"
66
"io/fs"
7-
"os"
87
"time"
98
)
109

@@ -73,9 +72,9 @@ type Basic interface {
7372
// instead. It opens the named file with specified flag (O_RDONLY etc.) and
7473
// perm, (0666 etc.) if applicable. If successful, methods on the returned
7574
// File can be used for I/O.
76-
OpenFile(filename string, flag int, perm os.FileMode) (File, error)
75+
OpenFile(filename string, flag int, perm fs.FileMode) (File, error)
7776
// Stat returns a FileInfo describing the named file.
78-
Stat(filename string) (os.FileInfo, error)
77+
Stat(filename string) (fs.FileInfo, error)
7978
// Rename renames (moves) oldpath to newpath. If newpath already exists and
8079
// is not a directory, Rename replaces it. OS-specific restrictions may
8180
// apply when oldpath and newpath are in different directories.
@@ -106,12 +105,12 @@ type TempFile interface {
106105
type Dir interface {
107106
// ReadDir reads the directory named by dirname and returns a list of
108107
// directory entries sorted by filename.
109-
ReadDir(path string) ([]os.FileInfo, error)
108+
ReadDir(path string) ([]fs.FileInfo, error)
110109
// MkdirAll creates a directory named path, along with any necessary
111110
// parents, and returns nil, or else returns an error. The permission bits
112111
// perm are used for all directories that MkdirAll creates. If path is/
113112
// already a directory, MkdirAll does nothing and returns nil.
114-
MkdirAll(filename string, perm os.FileMode) error
113+
MkdirAll(filename string, perm fs.FileMode) error
115114
}
116115

117116
// Symlink abstract the symlink related operations in a storage-agnostic
@@ -120,7 +119,7 @@ type Symlink interface {
120119
// Lstat returns a FileInfo describing the named file. If the file is a
121120
// symbolic link, the returned FileInfo describes the symbolic link. Lstat
122121
// makes no attempt to follow the link.
123-
Lstat(filename string) (os.FileInfo, error)
122+
Lstat(filename string) (fs.FileInfo, error)
124123
// Symlink creates a symbolic-link from link to target. target may be an
125124
// absolute or relative path, and need not refer to an existing node.
126125
// Parent directories of link are created as necessary.
@@ -134,7 +133,7 @@ type Symlink interface {
134133
type Change interface {
135134
// Chmod changes the mode of the named file to mode. If the file is a
136135
// symbolic link, it changes the mode of the link's target.
137-
Chmod(name string, mode os.FileMode) error
136+
Chmod(name string, mode fs.FileMode) error
138137
// Lchown changes the numeric uid and gid of the named file. If the file is
139138
// a symbolic link, it changes the uid and gid of the link itself.
140139
Lchown(name string, uid, gid int) error

helper/chroot/chroot.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package chroot
22

33
import (
4+
"io/fs"
45
"os"
56
"path/filepath"
67
"strings"
@@ -68,7 +69,7 @@ func (fs *ChrootHelper) Open(filename string) (billy.File, error) {
6869
return newFile(fs, f, filename), nil
6970
}
7071

71-
func (fs *ChrootHelper) OpenFile(filename string, flag int, mode os.FileMode) (billy.File, error) {
72+
func (fs *ChrootHelper) OpenFile(filename string, flag int, mode fs.FileMode) (billy.File, error) {
7273
fullpath, err := fs.underlyingPath(filename)
7374
if err != nil {
7475
return nil, err
@@ -142,7 +143,7 @@ func (fs *ChrootHelper) ReadDir(path string) ([]os.FileInfo, error) {
142143
return fs.underlying.(billy.Dir).ReadDir(fullpath)
143144
}
144145

145-
func (fs *ChrootHelper) MkdirAll(filename string, perm os.FileMode) error {
146+
func (fs *ChrootHelper) MkdirAll(filename string, perm fs.FileMode) error {
146147
fullpath, err := fs.underlyingPath(filename)
147148
if err != nil {
148149
return err

helper/mount/mount.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package mount
22

33
import (
44
"io"
5+
"io/fs"
56
"os"
67
"path/filepath"
78
"strings"
@@ -53,7 +54,7 @@ func (h *Mount) Open(path string) (billy.File, error) {
5354
return wrapFile(f, path), err
5455
}
5556

56-
func (h *Mount) OpenFile(path string, flag int, mode os.FileMode) (billy.File, error) {
57+
func (h *Mount) OpenFile(path string, flag int, mode fs.FileMode) (billy.File, error) {
5758
fs, fullpath := h.getBasicAndPath(path)
5859
if fullpath == "." {
5960
return nil, os.ErrInvalid
@@ -118,7 +119,7 @@ func (h *Mount) ReadDir(path string) ([]os.FileInfo, error) {
118119
return fs.ReadDir(fullpath)
119120
}
120121

121-
func (h *Mount) MkdirAll(filename string, perm os.FileMode) error {
122+
func (h *Mount) MkdirAll(filename string, perm fs.FileMode) error {
122123
fs, fullpath, err := h.getDirAndPath(filename)
123124
if err != nil {
124125
return err

helper/polyfill/polyfill.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package polyfill
22

33
import (
4+
"io/fs"
45
"os"
56
"path/filepath"
67

@@ -47,7 +48,7 @@ func (h *Polyfill) ReadDir(path string) ([]os.FileInfo, error) {
4748
return h.Basic.(billy.Dir).ReadDir(path)
4849
}
4950

50-
func (h *Polyfill) MkdirAll(filename string, perm os.FileMode) error {
51+
func (h *Polyfill) MkdirAll(filename string, perm fs.FileMode) error {
5152
if !h.c.dir {
5253
return billy.ErrNotSupported
5354
}

internal/test/mock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (fs *BasicMock) Open(filename string) (billy.File, error) {
3030
return &FileMock{name: filename}, nil
3131
}
3232

33-
func (fs *BasicMock) OpenFile(filename string, flag int, mode os.FileMode) (billy.File, error) {
33+
func (fs *BasicMock) OpenFile(filename string, flag int, mode fs.FileMode) (billy.File, error) {
3434
fs.OpenFileArgs = append(fs.OpenFileArgs, [3]interface{}{filename, flag, mode})
3535
return &FileMock{name: filename}, nil
3636
}
@@ -76,7 +76,7 @@ func (fs *DirMock) ReadDir(path string) ([]os.FileInfo, error) {
7676
return nil, nil
7777
}
7878

79-
func (fs *DirMock) MkdirAll(filename string, perm os.FileMode) error {
79+
func (fs *DirMock) MkdirAll(filename string, perm fs.FileMode) error {
8080
fs.MkdirAllArgs = append(fs.MkdirAllArgs, [2]interface{}{filename, perm})
8181
return nil
8282
}

memfs/memory.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"io/fs"
89
"os"
910
"path/filepath"
1011
"sort"
@@ -43,7 +44,7 @@ func (fs *Memory) Open(filename string) (billy.File, error) {
4344
return fs.OpenFile(filename, os.O_RDONLY, 0)
4445
}
4546

46-
func (fs *Memory) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error) {
47+
func (fs *Memory) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error) {
4748
f, has := fs.s.Get(filename)
4849
if !has {
4950
if !isCreate(flag) {
@@ -154,7 +155,7 @@ func (fs *Memory) ReadDir(path string) ([]os.FileInfo, error) {
154155
return entries, nil
155156
}
156157

157-
func (fs *Memory) MkdirAll(path string, perm os.FileMode) error {
158+
func (fs *Memory) MkdirAll(path string, perm fs.FileMode) error {
158159
_, err := fs.s.New(path, perm|os.ModeDir, 0)
159160
return err
160161
}
@@ -318,7 +319,7 @@ func (f *file) Truncate(size int64) error {
318319
return nil
319320
}
320321

321-
func (f *file) Duplicate(filename string, mode os.FileMode, flag int) billy.File {
322+
func (f *file) Duplicate(filename string, mode fs.FileMode, flag int) billy.File {
322323
new := &file{
323324
name: filename,
324325
content: f.content,
@@ -372,7 +373,7 @@ func (fi *fileInfo) Size() int64 {
372373
return int64(fi.size)
373374
}
374375

375-
func (fi *fileInfo) Mode() os.FileMode {
376+
func (fi *fileInfo) Mode() fs.FileMode {
376377
return fi.mode
377378
}
378379

@@ -424,6 +425,6 @@ func isWriteOnly(flag int) bool {
424425
return flag&os.O_WRONLY != 0
425426
}
426427

427-
func isSymlink(m os.FileMode) bool {
428+
func isSymlink(m fs.FileMode) bool {
428429
return m&os.ModeSymlink != 0
429430
}

memfs/storage.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"io"
7+
"io/fs"
78
"os"
89
"path/filepath"
910
"strings"
@@ -30,7 +31,7 @@ func (s *storage) Has(path string) bool {
3031
return ok
3132
}
3233

33-
func (s *storage) New(path string, mode os.FileMode, flag int) (*file, error) {
34+
func (s *storage) New(path string, mode fs.FileMode, flag int) (*file, error) {
3435
path = clean(path)
3536
if s.Has(path) {
3637
if !s.MustGet(path).mode.IsDir() {
@@ -55,7 +56,7 @@ func (s *storage) New(path string, mode os.FileMode, flag int) (*file, error) {
5556
return f, nil
5657
}
5758

58-
func (s *storage) createParent(path string, mode os.FileMode, f *file) error {
59+
func (s *storage) createParent(path string, mode fs.FileMode, f *file) error {
5960
base := filepath.Dir(path)
6061
base = clean(base)
6162
if f.Name() == string(separator) {

osfs/os.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func tempFile(dir, prefix string) (billy.File, error) {
103103
return &file{File: f}, nil
104104
}
105105

106-
func openFile(fn string, flag int, perm os.FileMode, createDir func(string) error) (billy.File, error) {
106+
func openFile(fn string, flag int, perm fs.FileMode, createDir func(string) error) (billy.File, error) {
107107
if flag&os.O_CREATE != 0 {
108108
if createDir == nil {
109109
return nil, fmt.Errorf("createDir func cannot be nil if file needs to be opened in create mode")

osfs/os_bound.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package osfs
2222
import (
2323
"errors"
2424
"fmt"
25+
"io/fs"
2526
"os"
2627
"path/filepath"
2728
"strings"
@@ -59,7 +60,7 @@ func (fs *BoundOS) Create(filename string) (billy.File, error) {
5960
return fs.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, defaultCreateMode)
6061
}
6162

62-
func (fs *BoundOS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error) {
63+
func (fs *BoundOS) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error) {
6364
filename = fs.expandDot(filename)
6465
fn, err := fs.abs(filename)
6566
if err != nil {
@@ -102,7 +103,7 @@ func (fs *BoundOS) Rename(from, to string) error {
102103
return os.Rename(f, t)
103104
}
104105

105-
func (fs *BoundOS) MkdirAll(path string, perm os.FileMode) error {
106+
func (fs *BoundOS) MkdirAll(path string, perm fs.FileMode) error {
106107
path = fs.expandDot(path)
107108
dir, err := fs.abs(path)
108109
if err != nil {

osfs/os_chroot.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package osfs
55

66
import (
7+
"io/fs"
78
"os"
89
"path/filepath"
910

@@ -31,7 +32,7 @@ func (fs *ChrootOS) Create(filename string) (billy.File, error) {
3132
return fs.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, defaultCreateMode)
3233
}
3334

34-
func (fs *ChrootOS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error) {
35+
func (fs *ChrootOS) OpenFile(filename string, flag int, perm fs.FileMode) (billy.File, error) {
3536
return openFile(filename, flag, perm, fs.createDir)
3637
}
3738

@@ -58,7 +59,7 @@ func (fs *ChrootOS) Rename(from, to string) error {
5859
return rename(from, to)
5960
}
6061

61-
func (fs *ChrootOS) MkdirAll(path string, perm os.FileMode) error {
62+
func (fs *ChrootOS) MkdirAll(path string, perm fs.FileMode) error {
6263
return os.MkdirAll(path, defaultDirectoryMode)
6364
}
6465

0 commit comments

Comments
 (0)