grumble/pkg/blobstore/lock_windows.go
2011-11-08 15:05:13 +01:00

26 lines
658 B
Go

// Copyright (c) 2011 The Grumble Authors
// The use of this source code is goverened by a BSD-style
// license that can be found in the LICENSE-file.
package blobstore
import "syscall"
const (
FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
)
// Acquire a lockfile at path.
func AcquireLockFile(path string) error {
handle, _ := syscall.CreateFile(syscall.StringToUTF16Ptr(path), syscall.GENERIC_WRITE, 0, nil, syscall.CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, 0)
if handle < 0 {
return ErrLocked
}
return nil
}
// Release the lockfile at path.
func ReleaseLockFile(path string) error {
// No-op because we use FLAG_DELETE_ON_CLOSE.
return nil
}