err == syscall.ERROR_FILE_EXISTS || err == ErrExist
}
+const _ERROR_BAD_NETPATH = syscall.Errno(53)
+
func isNotExist(err error) bool {
switch pe := err.(type) {
case nil:
err = pe.Err
}
return err == syscall.ERROR_FILE_NOT_FOUND ||
+ err == _ERROR_BAD_NETPATH ||
err == syscall.ERROR_PATH_NOT_FOUND || err == ErrNotExist
}
defer p.Wait()
t.Fatalf("StartProcess expected to fail, but succeeded.")
}
+
+func TestShareNotExistError(t *testing.T) {
+ if testing.Short() {
+ t.Skip("slow test that uses network; skipping")
+ }
+ _, err := os.Stat(`\\no_such_server\no_such_share\no_such_file`)
+ if err == nil {
+ t.Fatal("stat succeeded, but expected to fail")
+ }
+ if !os.IsNotExist(err) {
+ t.Fatalf("os.Stat failed with %q, but os.IsNotExist(err) is false", err)
+ }
+}
+
+func TestBadNetPathError(t *testing.T) {
+ const ERROR_BAD_NETPATH = syscall.Errno(53)
+ if !os.IsNotExist(ERROR_BAD_NETPATH) {
+ t.Fatal("os.IsNotExist(syscall.Errno(53)) is false, but want true")
+ }
+}