...
Run Format

Source file src/os/error_windows.go

     1	// Copyright 2012 The Go Authors. All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	package os
     6	
     7	import "syscall"
     8	
     9	func isExist(err error) bool {
    10		switch pe := err.(type) {
    11		case nil:
    12			return false
    13		case *PathError:
    14			err = pe.Err
    15		case *LinkError:
    16			err = pe.Err
    17		case *SyscallError:
    18			err = pe.Err
    19		}
    20		return err == syscall.ERROR_ALREADY_EXISTS ||
    21			err == syscall.ERROR_FILE_EXISTS || err == ErrExist
    22	}
    23	
    24	const _ERROR_BAD_NETPATH = syscall.Errno(53)
    25	
    26	func isNotExist(err error) bool {
    27		switch pe := err.(type) {
    28		case nil:
    29			return false
    30		case *PathError:
    31			err = pe.Err
    32		case *LinkError:
    33			err = pe.Err
    34		case *SyscallError:
    35			err = pe.Err
    36		}
    37		return err == syscall.ERROR_FILE_NOT_FOUND ||
    38			err == _ERROR_BAD_NETPATH ||
    39			err == syscall.ERROR_PATH_NOT_FOUND || err == ErrNotExist
    40	}
    41	
    42	func isPermission(err error) bool {
    43		switch pe := err.(type) {
    44		case nil:
    45			return false
    46		case *PathError:
    47			err = pe.Err
    48		case *LinkError:
    49			err = pe.Err
    50		case *SyscallError:
    51			err = pe.Err
    52		}
    53		return err == syscall.ERROR_ACCESS_DENIED || err == ErrPermission
    54	}
    55	

View as plain text