add importing from prefix
This commit is contained in:
parent
29a20324a6
commit
b83e530392
11 changed files with 287 additions and 22 deletions
|
|
@ -42,6 +42,24 @@ function prefixExists(name) {
|
|||
}
|
||||
}
|
||||
|
||||
// Where the Windows C: drive of a prefix actually lives: plain wine keeps
|
||||
// it at the top (WINEPREFIX=<prefix>), Proton-managed prefixes nest it
|
||||
// under pfx/ (WINEPREFIX=<prefix>/pfx). system.reg marks the real prefix
|
||||
// root; a fresh prefix may not have it yet, so fall back to drive_c itself.
|
||||
function prefixDriveRoot(name) {
|
||||
const root = prefixPath(name)
|
||||
for (const pass of [true, false]) {
|
||||
for (const base of [root, path.join(root, 'pfx')]) {
|
||||
try {
|
||||
const driveC = path.join(base, 'drive_c')
|
||||
if (!fs.statSync(driveC).isDirectory()) continue
|
||||
if (!pass || fs.existsSync(path.join(base, 'system.reg'))) return driveC
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function createPrefix(name) {
|
||||
const clean = normalizeName(name)
|
||||
if (!clean) return { ok: false, error: 'invalidName' }
|
||||
|
|
@ -75,4 +93,4 @@ function setDefaultPrefix(name) {
|
|||
return { ok: true }
|
||||
}
|
||||
|
||||
module.exports = { listPrefixes, createPrefix, deletePrefix, setDefaultPrefix, prefixPath, prefixExists, normalizeName, MAIN }
|
||||
module.exports = { listPrefixes, createPrefix, deletePrefix, setDefaultPrefix, prefixPath, prefixExists, prefixDriveRoot, normalizeName, MAIN }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue