2012-03-30 23:27:11 +02:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package os
|
|
|
|
|
|
|
|
import "syscall"
|
|
|
|
|
2012-03-31 00:09:55 +02:00
|
|
|
func isExist(err error) bool {
|
2012-03-30 23:27:11 +02:00
|
|
|
if pe, ok := err.(*PathError); ok {
|
|
|
|
err = pe.Err
|
|
|
|
}
|
2012-03-31 00:09:55 +02:00
|
|
|
return err == syscall.ERROR_ALREADY_EXISTS ||
|
2012-03-30 23:27:11 +02:00
|
|
|
err == syscall.ERROR_FILE_EXISTS || err == ErrExist
|
|
|
|
}
|
|
|
|
|
2012-03-31 00:09:55 +02:00
|
|
|
func isNotExist(err error) bool {
|
2012-03-30 23:27:11 +02:00
|
|
|
if pe, ok := err.(*PathError); ok {
|
|
|
|
err = pe.Err
|
|
|
|
}
|
2012-03-31 00:09:55 +02:00
|
|
|
return err == syscall.ERROR_FILE_NOT_FOUND ||
|
|
|
|
err == syscall.ERROR_PATH_NOT_FOUND || err == ErrNotExist
|
2012-03-30 23:27:11 +02:00
|
|
|
}
|
|
|
|
|
2012-03-31 00:09:55 +02:00
|
|
|
func isPermission(err error) bool {
|
2012-03-30 23:27:11 +02:00
|
|
|
if pe, ok := err.(*PathError); ok {
|
|
|
|
err = pe.Err
|
|
|
|
}
|
2012-05-04 17:01:11 +02:00
|
|
|
return err == syscall.ERROR_ACCESS_DENIED || err == ErrPermission
|
2012-03-30 23:27:11 +02:00
|
|
|
}
|