in providers/windows/device_windows.go [110:150]
func (mapper *deviceMapper) DevicePathToDrivePath(path string) (string, error) {
pathLower := strings.ToLower(path)
isMUP := strings.Index(pathLower, DeviceMup) == 0
mask, err := mapper.GetLogicalDrives()
if err != nil {
return "", fmt.Errorf("GetLogicalDrives: %w", err)
}
for bit := uint32(0); mask != 0 && bit < uint32('Z'-'A'+1); bit++ {
if mask&(1<<bit) == 0 {
continue
}
mask ^= 1 << bit
driveLetter := byte('A' + bit)
dev, err := mapper.getDevice(driveLetter)
if err != nil {
continue
}
dev = fixNetworkDrivePath(strings.ToLower(dev))
found := strings.Index(pathLower, dev) == 0
if !found && isMUP && strings.Contains(dev, LANManRedirector) {
dev = strings.Replace(dev, LANManRedirector, "mup", 1)
found = strings.Index(pathLower, dev) == 0
}
if found {
off := len(dev)
if off < len(path) && path[off] == '\\' {
off++
}
return string(driveLetter) + ":\\" + path[off:], nil
}
}
// Handle unmapped shares:
// \device\mup\server\share\path -> \\server\share\path
if isMUP {
return "\\" + path[len(DeviceMup):], nil
}
return "", ErrDeviceNotFound
}