golang.org/x/build@v0.0.0-20240506185731-218518f32b70/maintner/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  const errSharingViolation syscall.Errno = 32 // Copied from internal/syscall/windows.ERROR_SHARING_VIOLATION
    14  
    15  // isEphemeralError returns true if err may be resolved by waiting.
    16  func isEphemeralError(err error) bool {
    17  	var errno syscall.Errno
    18  	if errors.As(err, &errno) {
    19  		switch errno {
    20  		case syscall.ERROR_ACCESS_DENIED,
    21  			syscall.ERROR_FILE_NOT_FOUND,
    22  			errSharingViolation:
    23  			return true
    24  		}
    25  	}
    26  	return false
    27  }