go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/auth/internal/file_windows.go (about) 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package internal 6 7 import ( 8 "os" 9 "syscall" 10 ) 11 12 // For reasons why this is needed: 13 // https://groups.google.com/d/topic/golang-dev/dS2GnwizSkk 14 15 func openSharedDelete(name string) (*os.File, error) { 16 lpFileName, err := syscall.UTF16PtrFromString(name) 17 if err != nil { 18 return nil, err 19 } 20 handle, err := syscall.CreateFile( 21 lpFileName, 22 uint32(syscall.GENERIC_READ), 23 uint32(syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE), 24 nil, 25 uint32(syscall.OPEN_EXISTING), 26 syscall.FILE_ATTRIBUTE_NORMAL, 0) 27 if err != nil { 28 return nil, err 29 } 30 return os.NewFile(uintptr(handle), name), nil 31 }