aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Engine/SaveSystem.cs
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-07-27 23:58:39 -0400
committerlempamo <[email protected]>2017-07-27 23:58:39 -0400
commit6b6369ba73c60d1b9472365ad96e5cd986e4c4f6 (patch)
tree201c6ba49d6d1cebc22c1ba04859766a3eb1157a /TimeHACK.Engine/SaveSystem.cs
parent7d3d306a8c0116273f45c1e1a08efc5347776b4f (diff)
downloadhistacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.tar.gz
histacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.tar.bz2
histacom2-6b6369ba73c60d1b9472365ad96e5cd986e4c4f6.zip
sweet new dos command (dir)
Diffstat (limited to 'TimeHACK.Engine/SaveSystem.cs')
-rw-r--r--TimeHACK.Engine/SaveSystem.cs18
1 files changed, 10 insertions, 8 deletions
diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs
index 226a68f..eaf3a5a 100644
--- a/TimeHACK.Engine/SaveSystem.cs
+++ b/TimeHACK.Engine/SaveSystem.cs
@@ -163,7 +163,7 @@ namespace TimeHACK.Engine
Directory.CreateDirectory(ProfileFileSystemDirectory);
SaveDirectoryInfo(ProfileDirectory, "folders", false, "My Computer", false);
- SaveDirectoryInfo(ProfileFileSystemDirectory, "CDrive", false, "Win95 (C:)", true);
+ SaveDirectoryInfo(ProfileFileSystemDirectory, "CDrive", false, "C:", true);
if (CurrentSave.CurrentOS == "95" || CurrentSave.CurrentOS == "98") SaveDirectoryInfo(ProfileMyComputerDirectory, "Doc", false, "My Documents", true);
if (CurrentSave.CurrentOS == "2000" || CurrentSave.CurrentOS == "ME") SaveDirectoryInfo(ProfileMyComputerDirectory, "Settings", false, "Documents and Settings", true);
SaveDirectoryInfo(ProfileMyComputerDirectory, "Prog", true, "Program Files", true);
@@ -194,12 +194,13 @@ namespace TimeHACK.Engine
CreateWindowsFile(ProfileWindowsDirectory, "explorer.exe", "explorer");
}
- public static void CreateWindowsFile(string filepath, string filename, string contents, int fileicon = 8)
+ public static void CreateWindowsFile(string filepath, string filename, string contents, int fileicon = 8, int bytes = 512)
{
File.WriteAllText(Path.Combine(filepath, filename), contents);
THFileInfo info = new THFileInfo();
info.Name = filename;
info.FileIcon = fileicon;
+ info.ByteSize = bytes;
UpdateDirectoryInfo(filepath, info);
}
@@ -222,6 +223,7 @@ namespace TimeHACK.Engine
if (File.ReadAllText(Path.Combine(path, "_data.info")).Contains(newfile.DOSName)) return;
FileSystemFolderInfo fsfi = JsonConvert.DeserializeObject<FileSystemFolderInfo>(File.ReadAllText(Path.Combine(path, "_data.info")));
fsfi.Files.Add(newfile);
+ fsfi.ByteSize += newfile.ByteSize;
string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented);
@@ -239,10 +241,6 @@ namespace TimeHACK.Engine
// All the above OSes share basically the same file layout!
// (Excluding Documents And Settings) which is 2000 and ME only
- // Rename the C Drive to Win98
-
- SaveDirectoryInfo(ProfileFileSystemDirectory, "CDrive", false, "Win98 (C:)", true);
-
// Add Address Book into existance!
SaveDirectoryInfo(ProfileProgramsDirectory, "Outlook Express", false, "Outlook Express", true);
@@ -258,8 +256,8 @@ namespace TimeHACK.Engine
public static void SaveDirectoryInfo(string parent, string dirname, bool isProtected, string label, bool allowback)
{
- if (!Directory.Exists(Path.Combine(parent, dirname)))
- Directory.CreateDirectory(Path.Combine(parent, dirname));
+ if (Directory.Exists(Path.Combine(parent, dirname)) && Path.Combine(parent, dirname) != ProfileFileSystemDirectory) return;
+ Directory.CreateDirectory(Path.Combine(parent, dirname));
FileSystemFolderInfo info = new FileSystemFolderInfo();
@@ -268,9 +266,11 @@ namespace TimeHACK.Engine
info.DOSLabel = info.Label.ToUpper().Replace("*", "").Replace("+", "").Replace(":", "").Replace(";", "").Replace(".", "").Replace(" ", "");
if (info.DOSLabel.Length > 8) info.DOSLabel = info.DOSLabel.Substring(0, 6) + "~1";
+ if (dirname == "C:") info.DOSLabel = "C:";
info.AllowBack = allowback;
info.Files = new List<THFileInfo>(256);
info.SubDirs = new List<THDirInfo>(256);
+ info.ByteSize = 0;
if (parent != ProfileDirectory)
{
@@ -655,6 +655,7 @@ namespace TimeHACK.Engine
public string Label { get; set; }
public string DOSLabel { get; set; }
public bool AllowBack { get; set; }
+ public int ByteSize { get; set; }
public List<THFileInfo> Files { get; set; }
public List<THDirInfo> SubDirs { get; set; }
}
@@ -664,6 +665,7 @@ namespace TimeHACK.Engine
public string Name { get; set; }
public string DOSName { get; set; }
public int FileIcon { get; set; }
+ public int ByteSize { get; set; }
}
public class THDirInfo