(3dc4135ce) v0.9.5.1
This commit is contained in:
@@ -12,8 +12,8 @@ namespace Barotrauma
|
||||
{
|
||||
partial class SaveUtil
|
||||
{
|
||||
private static string LegacySaveFolder = Path.Combine("Data", "Saves");
|
||||
private static string LegacyMultiplayerSaveFolder = Path.Combine(LegacySaveFolder, "Multiplayer");
|
||||
private static readonly string LegacySaveFolder = Path.Combine("Data", "Saves");
|
||||
private static readonly string LegacyMultiplayerSaveFolder = Path.Combine(LegacySaveFolder, "Multiplayer");
|
||||
|
||||
#if OSX
|
||||
//"/*user*/Library/Application Support/Daedalic Entertainment GmbH/" on Mac
|
||||
@@ -32,9 +32,10 @@ namespace Barotrauma
|
||||
"Barotrauma");
|
||||
#endif
|
||||
|
||||
public static string MultiplayerSaveFolder = Path.Combine(
|
||||
SaveFolder,
|
||||
"Multiplayer");
|
||||
public static string MultiplayerSaveFolder = Path.Combine(SaveFolder, "Multiplayer");
|
||||
|
||||
public static readonly string SubmarineDownloadFolder = Path.Combine("Submarines", "Downloaded");
|
||||
public static readonly string CampaignDownloadFolder = Path.Combine("Data", "Saves", "Multiplayer");
|
||||
|
||||
public delegate void ProgressDelegate(string sMessage);
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace Barotrauma
|
||||
get { return Path.Combine(SaveFolder, "temp"); }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public enum SaveType
|
||||
{
|
||||
Singleplayer,
|
||||
@@ -208,11 +209,11 @@ namespace Barotrauma
|
||||
if (Directory.Exists(legacyFolder))
|
||||
{
|
||||
files.AddRange(Directory.GetFiles(legacyFolder, "*.save"));
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
public static string CreateSavePath(SaveType saveType, string fileName = "Save_Default")
|
||||
{
|
||||
fileName = ToolBox.RemoveInvalidFileNameChars(fileName);
|
||||
@@ -229,7 +230,7 @@ namespace Barotrauma
|
||||
DebugConsole.Log("Save folder \"" + folder + "\" not found. Created new folder");
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
|
||||
string extension = ".save";
|
||||
string pathWithoutExtension = Path.Combine(folder, fileName);
|
||||
|
||||
@@ -246,7 +247,7 @@ namespace Barotrauma
|
||||
|
||||
return pathWithoutExtension + " " + i + extension;
|
||||
}
|
||||
|
||||
|
||||
public static void CompressStringToFile(string fileName, string value)
|
||||
{
|
||||
// A.
|
||||
@@ -296,8 +297,7 @@ namespace Barotrauma
|
||||
foreach (string sFilePath in sFiles)
|
||||
{
|
||||
string sRelativePath = sFilePath.Substring(iDirLen);
|
||||
if (progress != null)
|
||||
progress(sRelativePath);
|
||||
progress?.Invoke(sRelativePath);
|
||||
CompressFile(sInDir, sRelativePath, str);
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ namespace Barotrauma
|
||||
int iNameLen = BitConverter.ToInt32(bytes, 0);
|
||||
if (iNameLen > 255)
|
||||
{
|
||||
throw new Exception("Failed to decompress \""+sDir+"\" (file name length > 255). The file may be corrupted.");
|
||||
throw new Exception("Failed to decompress \"" + sDir + "\" (file name length > 255). The file may be corrupted.");
|
||||
}
|
||||
|
||||
bytes = new byte[sizeof(char)];
|
||||
@@ -340,8 +340,7 @@ namespace Barotrauma
|
||||
sb.Append(c);
|
||||
}
|
||||
string sFileName = sb.ToString();
|
||||
if (progress != null)
|
||||
progress(sFileName);
|
||||
progress?.Invoke(sFileName);
|
||||
|
||||
//Decompress file content
|
||||
bytes = new byte[sizeof(int)];
|
||||
@@ -438,9 +437,23 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearFolder(string FolderName, string[] ignoredFileNames = null)
|
||||
public static void CleanUnnecessarySaveFiles()
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(FolderName);
|
||||
if (Directory.Exists(CampaignDownloadFolder))
|
||||
{
|
||||
ClearFolder(CampaignDownloadFolder);
|
||||
Directory.Delete(CampaignDownloadFolder);
|
||||
}
|
||||
if (Directory.Exists(TempPath))
|
||||
{
|
||||
ClearFolder(TempPath);
|
||||
Directory.Delete(TempPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearFolder(string folderName, string[] ignoredFileNames = null)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(folderName);
|
||||
|
||||
foreach (FileInfo fi in dir.GetFiles())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user