Auto launch Steam shortcut fixes

This commit is contained in:
Natsumi
2026-03-15 00:10:20 +11:00
committed by pa
parent d59a0a3894
commit cde18c653c

View File

@@ -526,66 +526,52 @@ namespace VRCX
return null; return null;
} }
string? testLibraryPath = null; var libraryFolders = new List<string>();
string? libraryPath = null;
foreach (var line in File.ReadLines(libraryFoldersVdfPath)) foreach (var line in File.ReadLines(libraryFoldersVdfPath))
{ {
if (line.Contains("\"path\"")) if (!line.Contains("\"path\""))
{ continue;
var parts = line.Split("\t");
if (parts.Length < 4)
continue;
var basePath = parts[4].Replace("\"", "").Replace(@"\\", @"\"); var parts = line.Split("\t");
var path = Path.Join(basePath, @"steamapps"); if (parts.Length < 4)
if (Directory.Exists(path)) continue;
testLibraryPath = path;
}
if (line.Contains($"\"{appId}\"")) var basePath = parts[4].Replace("\"", "").Replace(@"\\", @"\");
{ var path = Path.Join(basePath, @"steamapps");
libraryPath = testLibraryPath; if (Directory.Exists(path))
break; libraryFolders.Add(path);
}
} }
if (libraryPath == null)
foreach (var libraryPath in libraryFolders)
{ {
logger.Error("Could not find Steam library containing appid {0}", appId); var appManifestFiles = Directory.GetFiles(libraryPath, "appmanifest_*.acf");
return null; foreach (var file in appManifestFiles)
}
string? installDir = null;
var appManifestFiles = Directory.GetFiles(libraryPath, "appmanifest_*.acf");
foreach (var file in appManifestFiles)
{
try
{ {
var acf = File.ReadAllText(file); try
var idMatch = Regex.Match(acf, @"""appid""\s+""(\d+)"""); {
var dirMatch = Regex.Match(acf, @"""installdir""\s+""([^""]+)"""); var acf = File.ReadAllText(file);
if (!idMatch.Success || !dirMatch.Success) var idMatch = Regex.Match(acf, @"""appid""\s+""(\d+)""");
continue; var dirMatch = Regex.Match(acf, @"""installdir""\s+""([^""]+)""");
if (!idMatch.Success || !dirMatch.Success)
continue;
var foundAppId = idMatch.Groups[1].Value; var foundAppId = idMatch.Groups[1].Value;
if (foundAppId != appId) if (foundAppId != appId)
continue; continue;
var fullPath = Path.Join(libraryPath, "common", dirMatch.Groups[1].Value); var fullPath = Path.Join(libraryPath, "common", dirMatch.Groups[1].Value);
if (Directory.Exists(fullPath)) if (Directory.Exists(fullPath))
installDir = fullPath; return fullPath;
} }
catch catch
{ {
// ignore // ignore
}
} }
} }
if (installDir == null)
{
logger.Error("Could not find install dir for appid {0}", appId);
return null;
}
return installDir; logger.Error("Could not find install dir for appid {0}", appId);
return null;
} }
} }
} }