/// <summary> /// Deletes this save's files, if serialized previously /// </summary> /// <returns></returns> public bool DeleteSerialization() { if (!serialized) { return(false); } if (!StratusIO.DeleteFile(filePath)) { this.LogError($"Failed to delete save file at {filePath}"); return(false); } if (snapshotLoaded || snapshotExists) { StratusIO.DeleteFile(snapshotFilePath); } OnDelete(); filePath = null; _snapshotFilePath = null; return(true); }
///// <summary> ///// Loads save data from the given file, generates if not present ///// </summary> ///// <param name="fileName"></param> ///// <param name="folderName"></param> ///// <returns></returns> //public SaveType LoadOrCreate(string fileName, string folderName = null) //{ // string filePath = ComposePath(fileName, folderName); // if (StratusIO.FileExists(filePath)) // { // return Load(fileName, folderName); // } // if (debug) // { // StratusDebug.Log($"Creating data at path {filePath}"); // } // return CreateSave(null, fileName); //} /// <summary> /// Deletes the save file at the default folder /// </summary> /// <param name="fileName"></param> /// <param name="folderName"></param> public bool Delete(string fileName, string folderName = null) { if (!Exists(fileName, saveDirectoryPath)) { return(false); } var fileNameExt = fileName + saveExtension; var filePath = saveDirectoryPath + fileNameExt; StratusIO.DeleteFile(ComposePath(fileName, folderName)); File.Delete(filePath); if (debug) { StratusDebug.Log($"Deleted data at path {filePath}"); } return(true); }
/// <summary> /// Clears all found save files (searches for them first) /// </summary> public void ClearSaveFiles() { RefreshSaveFiles(); if (saveFilePaths.IsValid()) { for (int i = 0; i < saveFilePaths.Length; i++) { string file = saveFilePaths[i]; StratusIO.DeleteFile(file); } if (debug) { this.Log($"Deleted {saveFilePaths.Length} save files!"); } } else if (debug) { this.LogWarning("No save files were found to be deleted."); } }