⬆️ Update dependencies
This commit is contained in:
+20
-5
@@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -57,6 +58,13 @@ type File interface {
|
||||
// A Dir implements FileSystem using the native file system restricted to a
|
||||
// specific directory tree.
|
||||
//
|
||||
// Dir does not prevent traversal of symbolic links within its directory tree,
|
||||
// including links that reference locations outside of the tree.
|
||||
//
|
||||
// Dir does not prevent filesystem modifications which change the target
|
||||
// of relative symbolic links. For example, moving a directory containing
|
||||
// a symbolic link to "../target" may cause the link to point to a new target.
|
||||
//
|
||||
// While the FileSystem.OpenFile method takes '/'-separated paths, a Dir's
|
||||
// string value is a filename on the native file system, not a URL, so it is
|
||||
// separated by filepath.Separator, which isn't necessarily '/'.
|
||||
@@ -162,6 +170,7 @@ type memFS struct {
|
||||
// - "/", "foo", false
|
||||
// - "/foo/", "bar", false
|
||||
// - "/foo/bar/", "x", true
|
||||
//
|
||||
// The frag argument will be empty only if dir is the root node and the walk
|
||||
// ends at that root node.
|
||||
func (fs *memFS) walk(op, fullname string, f func(dir *memFSNode, frag string, final bool) error) error {
|
||||
@@ -272,8 +281,14 @@ func (fs *memFS) OpenFile(ctx context.Context, name string, flag int, perm os.Fi
|
||||
var n *memFSNode
|
||||
if dir == nil {
|
||||
// We're opening the root.
|
||||
if flag&(os.O_WRONLY|os.O_RDWR) != 0 {
|
||||
return nil, os.ErrPermission
|
||||
if runtime.GOOS == "zos" {
|
||||
if flag&os.O_WRONLY != 0 {
|
||||
return nil, os.ErrPermission
|
||||
}
|
||||
} else {
|
||||
if flag&(os.O_WRONLY|os.O_RDWR) != 0 {
|
||||
return nil, os.ErrPermission
|
||||
}
|
||||
}
|
||||
n, frag = &fs.root, "/"
|
||||
|
||||
@@ -539,11 +554,11 @@ func (f *memFile) Seek(offset int64, whence int) (int64, error) {
|
||||
npos := f.pos
|
||||
// TODO: How to handle offsets greater than the size of system int?
|
||||
switch whence {
|
||||
case os.SEEK_SET:
|
||||
case io.SeekStart:
|
||||
npos = int(offset)
|
||||
case os.SEEK_CUR:
|
||||
case io.SeekCurrent:
|
||||
npos += int(offset)
|
||||
case os.SEEK_END:
|
||||
case io.SeekEnd:
|
||||
npos = len(f.n.data) + int(offset)
|
||||
default:
|
||||
npos = -1
|
||||
|
||||
Reference in New Issue
Block a user