diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-08-27 17:38:37 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-08-27 17:38:37 +0100 |
| commit | 579ed261e4b035449ca838b9d852ae602a9b76bf (patch) | |
| tree | 87066515fd61a265e12743f9c2ebaa2c806f51fe /Histacom2.Engine/SaveSystem.cs | |
| parent | 15b5a609e1a60035b74aebfc70fafd8e118e4c3a (diff) | |
| parent | d5d50c6c205b505ea6f4dcae90b3797ed6c180f7 (diff) | |
| download | histacom2-579ed261e4b035449ca838b9d852ae602a9b76bf.tar.gz histacom2-579ed261e4b035449ca838b9d852ae602a9b76bf.tar.bz2 histacom2-579ed261e4b035449ca838b9d852ae602a9b76bf.zip | |
Updated my fork!
Conflicts:
Histacom2/OS/Win95/Win95Apps/Win95WindowsExplorer.Designer.cs
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; + } } } |
