|
|
|
@ -24,6 +24,9 @@ import ( |
|
|
|
|
|
|
|
|
|
// Function not implemented error
|
|
|
|
|
func isSysErrNoSys(err error) bool { |
|
|
|
|
if err == syscall.ENOSYS { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.ENOSYS: |
|
|
|
@ -35,6 +38,9 @@ func isSysErrNoSys(err error) bool { |
|
|
|
|
|
|
|
|
|
// Not supported error
|
|
|
|
|
func isSysErrOpNotSupported(err error) bool { |
|
|
|
|
if err == syscall.EOPNOTSUPP { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.EOPNOTSUPP: |
|
|
|
@ -46,6 +52,9 @@ func isSysErrOpNotSupported(err error) bool { |
|
|
|
|
|
|
|
|
|
// No space left on device error
|
|
|
|
|
func isSysErrNoSpace(err error) bool { |
|
|
|
|
if err == syscall.ENOSPC { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.ENOSPC: |
|
|
|
@ -57,6 +66,9 @@ func isSysErrNoSpace(err error) bool { |
|
|
|
|
|
|
|
|
|
// Input/output error
|
|
|
|
|
func isSysErrIO(err error) bool { |
|
|
|
|
if err == syscall.EIO { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.EIO: |
|
|
|
@ -68,6 +80,9 @@ func isSysErrIO(err error) bool { |
|
|
|
|
|
|
|
|
|
// Check if the given error corresponds to EISDIR (is a directory).
|
|
|
|
|
func isSysErrIsDir(err error) bool { |
|
|
|
|
if err == syscall.EISDIR { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.EISDIR: |
|
|
|
@ -79,6 +94,9 @@ func isSysErrIsDir(err error) bool { |
|
|
|
|
|
|
|
|
|
// Check if the given error corresponds to ENOTDIR (is not a directory).
|
|
|
|
|
func isSysErrNotDir(err error) bool { |
|
|
|
|
if err == syscall.ENOTDIR { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.ENOTDIR: |
|
|
|
@ -90,6 +108,9 @@ func isSysErrNotDir(err error) bool { |
|
|
|
|
|
|
|
|
|
// Check if the given error corresponds to the ENAMETOOLONG (name too long).
|
|
|
|
|
func isSysErrTooLong(err error) bool { |
|
|
|
|
if err == syscall.ENAMETOOLONG { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
switch pathErr.Err { |
|
|
|
|
case syscall.ENAMETOOLONG: |
|
|
|
@ -102,6 +123,9 @@ func isSysErrTooLong(err error) bool { |
|
|
|
|
// Check if the given error corresponds to ENOTEMPTY for unix
|
|
|
|
|
// and ERROR_DIR_NOT_EMPTY for windows (directory not empty).
|
|
|
|
|
func isSysErrNotEmpty(err error) bool { |
|
|
|
|
if err == syscall.ENOTEMPTY { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
if pathErr, ok := err.(*os.PathError); ok { |
|
|
|
|
if runtime.GOOS == globalWindowsOSName { |
|
|
|
|
if errno, _ok := pathErr.Err.(syscall.Errno); _ok && errno == 0x91 { |
|
|
|
|