예제 #1
0
        List <Library> detectSteamLibraries(string steamPath, List <Library> libraryList)
        {
            libraryList.Clear();
            ValveFileReader vfr = new ValveFileReader();

            vfr.readFile(steamPath + "\\steamapps\\libraryfolders.vdf");
            if (vfr.name != "LibraryFolders")
            {
                return(null);
            }
            Library library = new Library();

            library.libraryDirectory = steamPath + "\\SteamApps";
            libraryList.Add(library);
            foreach (ValveFileItem vfi in vfr.itemsList)
            {
                if (vfi.name.Equals("TimeNextStatsReport") || vfi.name.Equals("ContentStatsID"))
                {
                    continue;
                }
                library = new Library();
                library.libraryDirectory = vfi.value + "\\SteamApps";
                libraryList.Add(library);
            }
            return(libraryList);
        }
예제 #2
0
        Library detectSteamGames(Library library)
        {
            string[]    filePaths = Directory.GetFiles(library.libraryDirectory, "*.acf");
            List <Game> gamesList = new List <Game>();

            foreach (string file in filePaths)
            {
                ValveFileReader vfr = new ValveFileReader();
                vfr.readFile(file);
                if (vfr.name != "AppState")
                {
                    return(null);
                }
                Game game = new Game();
                foreach (ValveFileItem vfi in vfr.itemsList)
                {
                    if (vfi.name.Equals("appID"))
                    {
                        game.appID = Convert.ToInt32(vfi.value);
                    }
                    else if (vfi.name.Equals("name"))
                    {
                        game.gameName = vfi.value;
                    }
                    else if (vfi.name.Equals("installdir"))
                    {
                        game.gameDirectory = vfi.value;
                    }
                    else if (vfi.name.Equals("SizeOnDisk"))
                    {
                        game.sizeOnDisk = Convert.ToInt64(vfi.value);
                    }
                }
                //game.realSizeOnDisk = GetWSHFolderSize(library.libraryDirectory + "\\common\\" + game.gameDirectory);
                if (game.realSizeOnDisk == -1)
                {
                    // usuń z listy, oznacz jako nieaktywny, coś jest nie tak z tym folderem.
                }
                gamesList.Add(game);
            }
            library.gamesList = gamesList;
            return(library);
        }