Browse Source

add volume type fun for windows

pull/103/head
Lunny Xiao 11 years ago
parent
commit
66fc81d36d
  1. 32
      cmd/helper_windows.go

32
cmd/helper_windows.go

@ -20,6 +20,38 @@ func makeLink(srcPath, destPath string) error {
return com.CopyDir(srcPath, destPath)
}
func volumnType(dir string) string {
pd := dir[:3]
dll := syscall.MustLoadDLL("kernel32.dll")
GetVolumeInformation := dll.MustFindProc("GetVolumeInformationW")
var volumeNameSize uint32 = 260
var nFileSystemNameSize, lpVolumeSerialNumber uint32
var lpFileSystemFlags, lpMaximumComponentLength uint32
var lpFileSystemNameBuffer, volumeName [260]byte
var ps *uint16 = syscall.StringToUTF16Ptr(pd)
_, _, _ = GetVolumeInformation.Call(uintptr(unsafe.Pointer(ps)),
uintptr(unsafe.Pointer(&volumeName)),
uintptr(volumeNameSize),
uintptr(unsafe.Pointer(&lpVolumeSerialNumber)),
uintptr(unsafe.Pointer(&lpMaximumComponentLength)),
uintptr(unsafe.Pointer(&lpFileSystemFlags)),
uintptr(unsafe.Pointer(&lpFileSystemNameBuffer)),
uintptr(unsafe.Pointer(&nFileSystemNameSize)), 0)
var bytes []byte
if lpFileSystemNameBuffer[6] == 0 {
bytes = []byte{lpFileSystemNameBuffer[0], lpFileSystemNameBuffer[2],
lpFileSystemNameBuffer[4]}
} else {
bytes = []byte{lpFileSystemNameBuffer[0], lpFileSystemNameBuffer[2],
lpFileSystemNameBuffer[4], lpFileSystemNameBuffer[6]}
}
return string(bytes)
}
func getWindowsVersion() int {
dll := syscall.MustLoadDLL("kernel32.dll")
p := dll.MustFindProc("GetVersion")

Loading…
Cancel
Save