mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: wsl reg
This commit is contained in:
@@ -5,9 +5,11 @@ import com.sun.jna.platform.win32.Advapi32Util
|
|||||||
import com.sun.jna.platform.win32.WinReg
|
import com.sun.jna.platform.win32.WinReg
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
|
||||||
object WSLSupport {
|
object WSLSupport {
|
||||||
|
private val log = LoggerFactory.getLogger(javaClass)
|
||||||
val isSupported by lazy { checkSupported() }
|
val isSupported by lazy { checkSupported() }
|
||||||
|
|
||||||
private fun checkSupported(): Boolean {
|
private fun checkSupported(): Boolean {
|
||||||
@@ -26,20 +28,29 @@ object WSLSupport {
|
|||||||
|
|
||||||
for (guid in guids) {
|
for (guid in guids) {
|
||||||
val key = baseKeyPath + "\\" + guid
|
val key = baseKeyPath + "\\" + guid
|
||||||
val distroName = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "DistributionName")
|
try {
|
||||||
val basePath = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "BasePath")
|
if (Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, key)) {
|
||||||
val flavor = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "Flavor")
|
val distroName =
|
||||||
if (StringUtils.isAnyBlank(distroName, guid, basePath, flavor)) continue
|
Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "DistributionName")
|
||||||
distributions.add(
|
val basePath = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "BasePath")
|
||||||
WSLDistribution(
|
val flavor = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, key, "Flavor")
|
||||||
guid = guid,
|
if (StringUtils.isAnyBlank(distroName, guid, basePath, flavor)) continue
|
||||||
flavor = flavor,
|
distributions.add(
|
||||||
basePath = basePath,
|
WSLDistribution(
|
||||||
distributionName = distroName
|
guid = guid,
|
||||||
)
|
flavor = flavor,
|
||||||
)
|
basePath = basePath,
|
||||||
|
distributionName = distroName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (log.isWarnEnabled) {
|
||||||
|
log.warn(e.message, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return distributions
|
return distributions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user