private string GetInstallPath(string steamInstallPath) { string installPath = string.Empty; string basePath = string.Format(@"{0}\{1}", steamInstallPath, "steamapps"); string[] files = Directory.GetFiles(basePath, "*.acf"); foreach (var file in files) { var reader = new AcfReader(file); if (reader.CheckIntegrity()) { var manifestObject = reader.ACFFileToStruct(); ACF_Struct appState = null; manifestObject.SubACF.TryGetValue("AppState", out appState); if (appState != null) { string gameName = null; appState.SubItems.TryGetValue("name", out gameName); if (gameName != null && gameName == ReflexNameInSteam) { installPath = string.Format(@"{0}\steamapps\common\{1}", steamInstallPath, manifestObject.SubACF["AppState"].SubItems["installdir"]); break; } } } } return(installPath); }
// // Load ACF files from a given directory and return the ACFs' data // static List <AppInfo> ReadSteamManifestsFromDir(string directory) { List <AppInfo> apps = new List <AppInfo>(); Console.WriteLine("Scanning for games in " + directory); if (Directory.Exists(directory)) { string[] files = Directory.GetFiles(directory); List <string> acfFiles = new List <string>(); foreach (string file in files) { if (file.Substring(file.Length - 4) == ".acf") { acfFiles.Add(file); } } foreach (string file in acfFiles) { AcfReader acfReader = new AcfReader(file); ACF_Struct acf = acfReader.ACFFileToStruct(); AppInfo app = new AppInfo(); app.name = acf.SubACF["AppState"].SubItems["name"]; app.id = acf.SubACF["AppState"].SubItems["appid"]; app.source = "Steam"; app.fileSource = file; apps.Add(app); //Console.WriteLine("Added " + app.name + " (" + app.id + ") to the database"); } } return(apps); }
private string[] GetLibraryFolders(string steamInstallPath) { List <string> libraryFolders = new List <string>(); string libraryFoldersManifest = string.Format(@"{0}\{1}\libraryfolders.vdf", steamInstallPath, "steamapps"); if (File.Exists(libraryFoldersManifest)) { var reader = new AcfReader(libraryFoldersManifest); if (reader.CheckIntegrity()) { var manifestObject = reader.ACFFileToStruct(); for (int i = 1; ; ++i) //infinite loop { if (manifestObject.SubACF["LibraryFolders"].SubItems.ContainsKey(i.ToString())) { libraryFolders.Add(manifestObject.SubACF["LibraryFolders"].SubItems[i.ToString()].Replace(@"\\", @"\")); } else // no more steam libraries { break; } } } } return(libraryFolders.ToArray()); }
// // Find extra Steam libraries // static string[] GetSteamLibraryFolders(string SteamAppsLocation) { List <string> outList = new List <string>(); if (Directory.Exists(SteamAppsLocation) && File.Exists(SteamAppsLocation + "/libraryfolders.vdf")) { AcfReader acfReader = new AcfReader(SteamAppsLocation + "/libraryfolders.vdf"); ACF_Struct acf = acfReader.ACFFileToStruct(); foreach (string key in acf.SubACF["LibraryFolders"].SubItems.Keys) { if (Regex.IsMatch(key, @"^\d+$")) { outList.Add(acf.SubACF["LibraryFolders"].SubItems[key] + "/steamapps"); Console.WriteLine("Found Steam library at " + acf.SubACF["LibraryFolders"].SubItems[key] + "/steamapps"); } } } return(outList.ToArray()); }