github.com/nalekseevs/itns-golangci-lint@v1.0.2/internal/robustio/robustio_windows.go (about)

     1  // Copyright 2019 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 robustio
     6  
     7  import (
     8  	"errors"
     9  	"syscall"
    10  )
    11  
    12  const errFileNotFound = syscall.ERROR_FILE_NOT_FOUND
    13  
    14  // ERROR_SHARING_VIOLATION (ldez) extract from go1.19.1/src/internal/syscall/windows/syscall_windows.go.
    15  // This is the only modification of this file.
    16  const ERROR_SHARING_VIOLATION syscall.Errno = 32
    17  
    18  // isEphemeralError returns true if err may be resolved by waiting.
    19  func isEphemeralError(err error) bool {
    20  	var errno syscall.Errno
    21  	if errors.As(err, &errno) {
    22  		switch errno {
    23  		case syscall.ERROR_ACCESS_DENIED,
    24  			syscall.ERROR_FILE_NOT_FOUND,
    25  			ERROR_SHARING_VIOLATION:
    26  			return true
    27  		}
    28  	}
    29  	return false
    30  }