Use removeall_noat variant on Windows
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build unix || wasip1 || windows
|
||||
//go:build unix || wasip1
|
||||
|
||||
package os
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (js && wasm) || plan9
|
||||
//go:build (js && wasm) || plan9 || windows
|
||||
|
||||
package os
|
||||
|
||||
|
||||
@@ -189,12 +189,6 @@ func (r *Root) Remove(name string) error {
|
||||
return rootRemove(r, name)
|
||||
}
|
||||
|
||||
// RemoveAll removes the named file or directory and any children that it contains.
|
||||
// See [RemoveAll] for more details.
|
||||
func (r *Root) RemoveAll(name string) error {
|
||||
return rootRemoveAll(r, name)
|
||||
}
|
||||
|
||||
// Stat returns a [FileInfo] describing the named file in the root.
|
||||
// See [Stat] for more details.
|
||||
func (r *Root) Stat(name string) (FileInfo, error) {
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"internal/filepathlite"
|
||||
"internal/stringslite"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -186,25 +185,6 @@ func rootRemove(r *Root, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootRemoveAll(r *Root, name string) error {
|
||||
if endsWithDot(name) {
|
||||
// Consistency with os.RemoveAll: Return EINVAL when trying to remove .
|
||||
return &PathError{Op: "RemoveAll", Path: name, Err: syscall.EINVAL}
|
||||
}
|
||||
if err := checkPathEscapesLstat(r, name); err != nil {
|
||||
if err == syscall.ENOTDIR {
|
||||
// Some intermediate path component is not a directory.
|
||||
// RemoveAll treats this as success (since the target doesn't exist).
|
||||
return nil
|
||||
}
|
||||
return &PathError{Op: "RemoveAll", Path: name, Err: err}
|
||||
}
|
||||
if err := RemoveAll(joinPath(r.root.name, name)); err != nil {
|
||||
return &PathError{Op: "RemoveAll", Path: name, Err: underlyingError(err)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootReadlink(r *Root, name string) (string, error) {
|
||||
if err := checkPathEscapesLstat(r, name); err != nil {
|
||||
return "", &PathError{Op: "readlinkat", Path: name, Err: err}
|
||||
|
||||
@@ -194,28 +194,6 @@ func rootRemove(r *Root, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootRemoveAll(r *Root, name string) error {
|
||||
// Consistency with os.RemoveAll: Strip trailing /s from the name,
|
||||
// so RemoveAll("not_a_directory/") succeeds.
|
||||
for len(name) > 0 && IsPathSeparator(name[len(name)-1]) {
|
||||
name = name[:len(name)-1]
|
||||
}
|
||||
if endsWithDot(name) {
|
||||
// Consistency with os.RemoveAll: Return EINVAL when trying to remove .
|
||||
return &PathError{Op: "RemoveAll", Path: name, Err: syscall.EINVAL}
|
||||
}
|
||||
_, err := doInRoot(r, name, nil, func(parent sysfdType, name string) (struct{}, error) {
|
||||
return struct{}{}, removeAllFrom(parent, name)
|
||||
})
|
||||
if IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return &PathError{Op: "RemoveAll", Path: name, Err: underlyingError(err)}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func rootRename(r *Root, oldname, newname string) error {
|
||||
_, err := doInRoot(r, oldname, nil, func(oldparent sysfdType, oldname string) (struct{}, error) {
|
||||
_, err := doInRoot(r, newname, nil, func(newparent sysfdType, newname string) (struct{}, error) {
|
||||
|
||||
Reference in New Issue
Block a user