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"); } }
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()}"); } }
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}"); } } }