diff options
| author | lempamo <[email protected]> | 2017-07-27 10:23:57 -0400 |
|---|---|---|
| committer | lempamo <[email protected]> | 2017-07-27 10:23:57 -0400 |
| commit | 2de78eddf69b017d24b67347468afc60767b5d2c (patch) | |
| tree | 3ece5d6b3f29b63a05c80ff16811e90c60e4b1dc /TimeHACK.Engine | |
| parent | b56050694f6473b13807a10d39881591e0f0f469 (diff) | |
| download | histacom2-2de78eddf69b017d24b67347468afc60767b5d2c.tar.gz histacom2-2de78eddf69b017d24b67347468afc60767b5d2c.tar.bz2 histacom2-2de78eddf69b017d24b67347468afc60767b5d2c.zip | |
dosname and icons for files! :smiley:
Diffstat (limited to 'TimeHACK.Engine')
| -rw-r--r-- | TimeHACK.Engine/SaveSystem.cs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/TimeHACK.Engine/SaveSystem.cs b/TimeHACK.Engine/SaveSystem.cs index 5886d41..f98abcd 100644 --- a/TimeHACK.Engine/SaveSystem.cs +++ b/TimeHACK.Engine/SaveSystem.cs @@ -203,18 +203,29 @@ namespace TimeHACK.Engine UpdateDirectoryInfo(filepath, info); } - [DllImport("kernel32.dll", SetLastError = true)] - private static extern int GetShortPathName(String pathName, StringBuilder shortName, int cbShortName); - public static void UpdateDirectoryInfo(string path, THFileInfo newfile) { - StringBuilder sb = new StringBuilder(300); - GetShortPathName(newfile.Name, sb, 300); - Regex rgx = new Regex(".{8}\\.[A-Z]{3}"); - newfile.DOSName = Regex.Match(sb.ToString(), rgx.ToString(), RegexOptions.RightToLeft).ToString(); + newfile.DOSName = newfile.Name.ToUpper().Replace("*", "").Replace("+", "").Replace(":", "").Replace(";", "").Replace(" ", ""); + string[] dos = newfile.DOSName.Split('.'); + + if (dos.Count() > 2) + { + List<string> dosb = dos.ToList(); + dosb.RemoveRange(1, dos.Count() - 2); + dos = dosb.ToArray(); + } + dos[1] = dos[1].Substring(0, 3); + Debug.Print(dos[0].Length.ToString()); + if (dos[0].Length > 8) + { + dos[0] = dos[0].Substring(0, 6) + "~1"; + } + + newfile.DOSName = dos[0] + "." + dos[1]; + 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[fsfi.Files.Count()] = newfile; + fsfi.Files.Add(newfile); string toWrite = JsonConvert.SerializeObject(fsfi, Formatting.Indented); @@ -259,7 +270,7 @@ namespace TimeHACK.Engine info.IsProtected = isProtected; info.Label = label; info.AllowBack = allowback; - info.Files = new THFileInfo[200]; + info.Files = new List<THFileInfo>(256); string toWrite = JsonConvert.SerializeObject(info, Formatting.Indented); @@ -632,7 +643,7 @@ namespace TimeHACK.Engine public bool IsProtected { get; set; } public string Label { get; set; } public bool AllowBack { get; set; } - public THFileInfo[] Files { get; set; } + public List<THFileInfo> Files { get; set; } } public class THFileInfo |
