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