Beispiel #1
0
        private void ReadItemsFromFiles(string grimDawnDirectory, bool keepExtractedFiles, Action <string> stateChangeCallback)
        {
            string[] dbFiles = GetDBFilesWithFullPaths(grimDawnDirectory);

            int i = 0;

            foreach (var file in dbFiles)
            {
                i++;

                stateChangeCallback("Extracting DB file " + file + " (" + i + " of " + dbFiles.Length + ")");
                LogHelper.GetLog().Debug("Processing: " + file);

                var extractPath = Path.Combine(Path.GetTempPath(), "GDArchiveTempPath", Path.GetFileNameWithoutExtension(file) + "_" + Guid.NewGuid().ToString());

                ArzExtractor.Extract(file, grimDawnDirectory, extractPath);

                stateChangeCallback("Reading items (file " + i + " of " + dbFiles.Length + ")");
                PopulateAllItems(extractPath, stateChangeCallback);

                if (!keepExtractedFiles)
                {
                    Directory.Delete(extractPath, true);
                }

                MD5Store.Instance.SetHash(file);
            }
        }
Beispiel #2
0
        private void ReadTagsFromFiles(string grimDawnDirectory)
        {
            string[] dbFiles =
            {
                "resources\\Text_EN.arc",
                "gdx1\\resources\\Text_EN.arc",
                "gdx2\\resources\\Text_EN.arc"
            };

            foreach (var file in dbFiles)
            {
                var fullFilePath = Path.Combine(grimDawnDirectory, file);

                if (!File.Exists(fullFilePath))
                {
                    continue;
                }

                var    tempArcFile   = GetTagFileCopy(fullFilePath);
                string extractedPath = Path.Combine(Path.GetTempPath(), "GDArchiveTempPath", Path.GetFileNameWithoutExtension(file) + "_" + Guid.NewGuid().ToString());

                try
                {
                    ArzExtractor.Extract(tempArcFile, grimDawnDirectory, extractedPath);
                    var tagsDir = Path.Combine(extractedPath, "text_en");
                    foreach (var f in Directory.EnumerateFiles(tagsDir, "*.txt", SearchOption.AllDirectories))
                    {
                        var tags = TagsReader.ReadAllTags(f);
                        foreach (var t in tags)
                        {
                            AllStrings[t.Key] = t.Value;
                        }
                    }
                    MD5Store.Instance.SetHash(fullFilePath);
                }
                finally
                {
                    var cleanupSetting = ConfigurationManager.AppSettings["cleanupArchiveFiles"];
                    var cleanup        = string.IsNullOrEmpty(cleanupSetting) || cleanupSetting.ToLowerInvariant() == "true";

                    if (cleanup)
                    {
                        if (extractedPath != null && Directory.Exists(extractedPath))
                        {
                            Directory.Delete(extractedPath, true);
                        }

                        var tempArcDir = Path.GetDirectoryName(tempArcFile);
                        if (Directory.Exists(tempArcDir))
                        {
                            Directory.Delete(tempArcDir, true);
                        }
                    }
                }
            }
        }