public void CopyFromStash2(string fileName)
        {
            // saving...
            // copy from areas folder to SaveGame

            try
            {
                var    areasFolder = AreaDataStash2.GetAreasFolder();
                string fileToCopy  = Path.Combine(areasFolder, fileName);

                // this check is missing in the FolderSaver.CopyFromStash
                if (File.Exists(fileToCopy))
                {
                    CopyFromStashBase(fileName);
                }
                else
                {
                    //BattleLogHelper.LogDebug($"doesnt exist: {fileToCopy}");
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"err {ex.ToString()}");
            }
        }
        public void CopyToStash(string fileName)
        {
            // m_FolderName: ...AppData\LocalLow\Owlcat Games\Pathfinder Kingmaker\Saved Games
            // areas folder: ...AppData/Local/Temp/Owlcat Games/Pathfinder Kingmaker\Areas

            var areasFolder = AreaDataStash2.GetAreasFolder();

            var saveGameFile = Path.Combine(m_FolderName, fileName);
            var destination  = Path.Combine(areasFolder, fileName);

            var fi1 = new FileInfo(saveGameFile);
            var fi2 = new FileInfo(destination);

            if (FileHelper2.FileHasChanges(fi1, fi2))
            {
                File.Delete(destination);

                BattleLogHelper.LogDebug($"has changes, copy to {destination}");
                CopyToStashBase(fileName);
            }
            else
            {
                // BattleLogHelper.LogDebug($"no changes");
            }
        }
        private void RemoveAllFilesNotInSaveGame()
        {
            if (m_SaveInfo?.Saver == null)
            {
                return;
            }

            var allFiles        = m_SaveInfo.Saver.GetAllFiles();
            var saveContentsDic = new HashSet <string>(allFiles);

            var areasFolder = AreaDataStash2.GetAreasFolder();

            Directory.CreateDirectory(areasFolder); // create if not exists

            // remove all files not in save
            foreach (var item in new DirectoryInfo(areasFolder).GetFiles())
            {
                var fileNameInArea = item.Name;

                if (!saveContentsDic.Contains(fileNameInArea))
                {
                    File.Delete(item.FullName);
                    BattleLogHelper.LogDebug($"not in save, delete {item.FullName}");
                }
            }
        }
        public ThreadedGameLoader2(SaveInfo m_SaveInfo, bool isSmokeTest)
        {
            this.m_SaveInfo    = m_SaveInfo;
            this.m_IsSmokeTest = isSmokeTest;

            try
            {
                // Usually AreaDataStash.ClearAll (clear area folder) is called before this ctor is invoked

                if (m_SaveInfo.Saver.GetType() == typeof(ZipSaver2))
                {
                    AreaDataStash2.ClearAll2(); // keep the old functionality
                }
                else
                {
                    RemoveAllFilesNotInSaveGame();
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"ThreadedGameLoader .ctor {ex.ToString()}");
            }
        }
 public new void LoadNewGame(BlueprintAreaPreset preset)
 {
     AreaDataStash2.ClearAll2(); // will call AreaDataStash.ClearAll2();
     LoadNewGameB(preset);
 }