diff options
Diffstat (limited to 'src/pkg/os/path.go')
-rw-r--r-- | src/pkg/os/path.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/pkg/os/path.go b/src/pkg/os/path.go index a8dfce307..02a77ec80 100644 --- a/src/pkg/os/path.go +++ b/src/pkg/os/path.go @@ -4,6 +4,11 @@ package os +import ( + "io" + "syscall" +) + // MkdirAll creates a directory named path, // along with any necessary parents, and returns nil, // or else returns an error. @@ -11,14 +16,14 @@ package os // directories that MkdirAll creates. // If path is already a directory, MkdirAll does nothing // and returns nil. -func MkdirAll(path string, perm uint32) Error { +func MkdirAll(path string, perm FileMode) error { // If path exists, stop with success or error. dir, err := Stat(path) if err == nil { - if dir.IsDirectory() { + if dir.IsDir() { return nil } - return &PathError{"mkdir", path, ENOTDIR} + return &PathError{"mkdir", path, syscall.ENOTDIR} } // Doesn't already exist; make sure parent does. @@ -46,7 +51,7 @@ func MkdirAll(path string, perm uint32) Error { // Handle arguments like "foo/." by // double-checking that directory doesn't exist. dir, err1 := Lstat(path) - if err1 == nil && dir.IsDirectory() { + if err1 == nil && dir.IsDir() { return nil } return err @@ -58,7 +63,7 @@ func MkdirAll(path string, perm uint32) Error { // It removes everything it can but returns the first error // it encounters. If the path does not exist, RemoveAll // returns nil (no error). -func RemoveAll(path string) Error { +func RemoveAll(path string) error { // Simple case: if Remove works, we're done. err := Remove(path) if err == nil { @@ -68,12 +73,12 @@ func RemoveAll(path string) Error { // Otherwise, is this a directory we need to recurse into? dir, serr := Lstat(path) if serr != nil { - if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT { + if serr, ok := serr.(*PathError); ok && (IsNotExist(serr.Err) || serr.Err == syscall.ENOTDIR) { return nil } return serr } - if !dir.IsDirectory() { + if !dir.IsDir() { // Not a directory; return the error from Remove. return err } @@ -94,7 +99,7 @@ func RemoveAll(path string) Error { err = err1 } } - if err1 == EOF { + if err1 == io.EOF { break } // If Readdirnames returned an error, use it. |