예제 #1
0
        public void BackupGame(SteamdumpGameMetadata input, FileInfo outputFile)
        {
            if (outputFile.Exists)
            {
                throw new FileAlreadyExistsException(outputFile.FullName);
            }
            XmlCommentary xc = new XmlCommentary();

            xc.magic      = "Azusa Steam Dumper";
            xc.acfName    = input.acfFile.Name;
            xc.acfContent = File.ReadAllText(input.acfFile.FullName);
            XmlSerializer xs = new XmlSerializer(xc.GetType());
            StringWriter  sw = new StringWriter();

            xs.Serialize(sw, xc);

            TextWriterLogAdapter twla = new TextWriterLogAdapter();
            ZipFile zip = new ZipFile(outputFile.FullName, twla, Encoding.UTF8);

            DirectoryInfo gameRoot = input.rootDirectory;

            FileInfo[] gameFiles = gameRoot.GetFiles("*", SearchOption.AllDirectories);
            string     cutoff    = gameRoot.FullName;

            zip.SaveProgress += (sender, e) => { TextWriterLogAdapter.LogCallback.SetProgress(e); };
            zip.AddDirectory(gameRoot.FullName);
            zip.Comment = sw.ToString();
            zip.Save();
        }
예제 #2
0
        private List <SteamdumpGameMetadata> GetGamesFromLibraryFolder(DirectoryInfo di)
        {
            List <SteamdumpGameMetadata> result = new List <SteamdumpGameMetadata>();

            foreach (FileInfo fi in di.GetFiles("*.acf"))
            {
                int      appId      = -1;
                string   name       = null;
                string   installdir = null;
                string[] acfLines   = File.ReadAllLines(fi.FullName);
                foreach (string acfLine in acfLines)
                {
                    if (acfLine.Contains("\"appid\""))
                    {
                        string acfArg = acfLine.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("\"", "");
                        appId = Convert.ToInt32(acfArg);
                    }
                    if (acfLine.Contains("\"name\""))
                    {
                        name = acfLine.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("\"", "");
                    }
                    if (acfLine.Contains("\"installdir\""))
                    {
                        installdir = acfLine.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("\"", "");
                    }
                    if (appId != -1 && name != null && installdir != null)
                    {
                        break;
                    }
                }
                DirectoryInfo         gameRoot = new DirectoryInfo(Path.Combine(di.FullName, "common", installdir));
                SteamdumpGameMetadata sdgm     = new SteamdumpGameMetadata(appId, name, fi, gameRoot);
                result.Add(sdgm);
            }
            return(result);
        }