Example #1
0
 private static void ParseValue(Stream stream, AppManifestItem o)
 {
     SkipWhitespace(stream);
     var c = (char) stream.ReadByte();
     if (c == '{')
     {
         o.Items = ParseObject(stream);
     }
     else if (c == '"')
     {
         stream.Seek(-1, SeekOrigin.Current);
         o.Value = ParseString(stream);
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Example #2
0
        private static Dictionary<string, AppManifestItem> ParseObject(Stream stream)
        {
            var d = new Dictionary<string, AppManifestItem>();
            while (true)
            {
                SkipWhitespace(stream);

                var b = stream.ReadByte();
                if (b == -1 || (char) b == '}')
                    return d;

                stream.Seek(-1, SeekOrigin.Current);

                var o = new AppManifestItem();
                o.Name = ParseString(stream);
                ParseValue(stream, o);
                d[o.Name] = o;
            }
        }
Example #3
0
        internal App(AppMetadata metadata, AppManifestItem manifest, string steamDir)
        {
            this.manifest = manifest;

            string gameName = manifest["UserConfig"].Items.ContainsKey("name") ? manifest["UserConfig"]["name"] : manifest["appID"];

            string baseDir;
            try
            {
                baseDir = manifest["UserConfig"].Items.ContainsKey("appinstalldir") ? manifest["UserConfig"]["appinstalldir"] : Path.Combine(steamDir, "common", manifest["installdir"]);
            }
            catch (KeyNotFoundException)
            {
                throw new IgnoreAppException("Game " + gameName + ": No installdir present in manifest");
            }

            if (baseDir.Length == 2 && baseDir[1] == ':')
            {
                throw new IgnoreAppException("Game " + gameName + ": invalid appinstalldir " + baseDir);
            }

            SteamSize = long.Parse(manifest["SizeOnDisk"]);

            DirectoryWalker walker;
            try
            {
                walker = DirectoryWalker.Walk(metadata, baseDir, Id);
            }
            catch (IgnoreAppException e)
            {
                throw new IgnoreAppException("Game " + gameName + ": " + e.Message);
            }
            Known = metadata.Known.Contains(Id);

            TotalSize = walker.TotalSize;
            if (!Known)
                return;

            DeletableSize = walker.DeletableSize;
            NotSelectedSize = walker.NotSelectedSize;

            DeletableFiles = walker.DeletableFiles;
        }