init: 自 zomaintain/backend/remote-core 平移独立成库; module path 改为 git.zeroonesoft.cn/golib/remote-core; 修复 ResizeDataType 未导出字段致 json tag 无效的遗留问题
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//go:build windows
|
||||
|
||||
package file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getVolumeName(device string) (string, error) {
|
||||
var volumes []Win32_Volume
|
||||
query := "SELECT Name, Label FROM Win32_Volume WHERE DriveType = 3" // DriveType = 3 表示磁盘分区
|
||||
|
||||
err := wmi.Query(query, &volumes)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to query Win32_Volume:", err)
|
||||
return device, err
|
||||
}
|
||||
|
||||
for _, volume := range volumes {
|
||||
// fmt.Println("Name:", volume.Name, "Label:", volume.Label)
|
||||
if strings.ToLower(volume.Name[:2]) == strings.ToLower(device[:2]) {
|
||||
return volume.Label, nil
|
||||
}
|
||||
}
|
||||
|
||||
return device, nil
|
||||
}
|
||||
Reference in New Issue
Block a user