mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 03:56:38 +08:00
chore: release MediaStationGo v0.0.31
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//go:build !unix
|
||||
//go:build !unix && !windows
|
||||
|
||||
package service
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//go:build windows
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func fileIdentity(path string) (string, bool) {
|
||||
ptr, err := windows.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
handle, err := windows.CreateFile(
|
||||
ptr,
|
||||
windows.GENERIC_READ,
|
||||
windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE|windows.FILE_SHARE_DELETE,
|
||||
nil,
|
||||
windows.OPEN_EXISTING,
|
||||
windows.FILE_FLAG_BACKUP_SEMANTICS,
|
||||
0,
|
||||
)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
defer windows.CloseHandle(handle)
|
||||
|
||||
var info windows.ByHandleFileInformation
|
||||
if err := windows.GetFileInformationByHandle(handle, &info); err != nil {
|
||||
return "", false
|
||||
}
|
||||
if info.NumberOfLinks < 2 {
|
||||
return "", false
|
||||
}
|
||||
fileIndex := (uint64(info.FileIndexHigh) << 32) | uint64(info.FileIndexLow)
|
||||
return fmt.Sprintf("%d:%d", info.VolumeSerialNumber, fileIndex), true
|
||||
}
|
||||
Reference in New Issue
Block a user