diff options
| author | Michael Webb <[email protected]> | 2017-08-27 14:21:12 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-08-27 14:21:12 -0500 |
| commit | 850e858d20ac95e8f758ca67ad6002909b8706c6 (patch) | |
| tree | d320aadf9d53ed8288711189ccac1da72191b257 /Histacom2.Engine/SaveSystem.cs | |
| parent | abfa46d41ef2b477f2a246fe1fdd9bae01165c0c (diff) | |
| parent | da23c51567cf9fd751cf97e7acb1ee6693a0f031 (diff) | |
| download | histacom2-850e858d20ac95e8f758ca67ad6002909b8706c6.tar.gz histacom2-850e858d20ac95e8f758ca67ad6002909b8706c6.tar.bz2 histacom2-850e858d20ac95e8f758ca67ad6002909b8706c6.zip | |
Merge pull request #1 from Histacom2-Devs/master
Merge latest changes from histacom repo
Diffstat (limited to 'Histacom2.Engine/SaveSystem.cs')
| -rw-r--r-- | Histacom2.Engine/SaveSystem.cs | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/Histacom2.Engine/SaveSystem.cs b/Histacom2.Engine/SaveSystem.cs index ef98c10..5557dca 100644 --- a/Histacom2.Engine/SaveSystem.cs +++ b/Histacom2.Engine/SaveSystem.cs @@ -235,36 +235,46 @@ namespace Histacom2.Engine File.WriteAllText(Path.Combine(path, "_data.info"), toWrite); } - public static void UpgradeFileSystem(string oldOS, string newOS) + public static void RemoveFileFromDirectory(string path, string filename) { - switch (oldOS) + FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(path, "_data.info"))); + THFileInfo fi = fsfi.Files.Find((THFileInfo f) => { return f.Name == filename; }); + if (fi == null) return; + + fsfi.ByteSize -= fi.ByteSize; + CurrentSave.BytesLeft += fi.ByteSize; + + fsfi.Files.Remove(fi); + string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented); + + File.WriteAllText(Path.Combine(path, "_data.info"), toWrite); + } + + public static void UpgradeFileSystem(string newOS) + { + if (newOS == "98" || newOS == "2000" || newOS == "ME") { - case "95": - if (newOS == "98" || newOS == "2000" || newOS == "ME") - { - // We are upgrading from the old WinClassic file System to the new WinClassic filesystem! - // All the above OSes share basically the same file layout! - // (Excluding Documents And Settings) which is 2000 and ME only + // We are upgrading from the old WinClassic file System to the new WinClassic filesystem! + // All the above OSes share basically the same file layout! + // (Excluding Documents And Settings) which is 2000 and ME only - // Add Address Book into existance! + // Add Address Book into existance! - SaveDirectoryInfo(ProfileProgramsDirectory, "Outlook Express", false, "Outlook Express", true); - CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), "WAB.exe", "addressbook", 8, 512); + SaveDirectoryInfo(ProfileProgramsDirectory, "Outlook Express", false, "Outlook Express", true); + CreateWindowsFile(Path.Combine(ProfileProgramsDirectory, "Outlook Express"), "WAB.exe", "addressbook", 8, 512); - // There is no "The Microsoft Network" folder! + // There is no "The Microsoft Network" folder! - if (Directory.Exists(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"))) Directory.Delete(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"), true); - FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(ProfileProgramsDirectory, "_data.info"))); - foreach (THDirInfo dir in fsfi.SubDirs) - { - if (dir.Name == "The Microsoft Network") - { - fsfi.SubDirs.Remove(dir); - break; - } - } + if (Directory.Exists(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"))) Directory.Delete(Path.Combine(ProfileProgramsDirectory, "The Microsoft Network"), true); + FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(ProfileProgramsDirectory, "_data.info"))); + foreach (THDirInfo dir in fsfi.SubDirs) + { + if (dir.Name == "The Microsoft Network") + { + fsfi.SubDirs.Remove(dir); + break; } - break; + } } } |
