From e0e7da7ac28c7c178f1a6c8413ae4cf71ec99122 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Tue, 24 Feb 2026 20:09:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E6=A3=80=E6=B5=8B+=E4=BF=AE=E5=A4=8D=E4=B8=80=E9=87=8D?= =?UTF-8?q?=E5=A4=A7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BuildTime.txt | 2 +- GitCommit.txt | 2 +- System/FileSystem.cs | 24 ++++++++++++++---------- System/UserSystem.cs | 4 ++-- editor/Nano.cs | 19 +++++++++++++------ 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/BuildTime.txt b/BuildTime.txt index 058c2d6..9201770 100644 --- a/BuildTime.txt +++ b/BuildTime.txt @@ -1 +1 @@ -2026-02-19 17:35:30 \ No newline at end of file +2026-02-24 20:06:20 \ No newline at end of file diff --git a/GitCommit.txt b/GitCommit.txt index c463ee1..297fba9 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -0147679 \ No newline at end of file +0386511 \ No newline at end of file diff --git a/System/FileSystem.cs b/System/FileSystem.cs index 415dea5..dfe512e 100644 --- a/System/FileSystem.cs +++ b/System/FileSystem.cs @@ -308,7 +308,11 @@ namespace CMLeonOS { if (File.Exists(fullPath)) { - return File.ReadAllText(fullPath); + using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) + using (StreamReader sr = new StreamReader(fs)) + { + return sr.ReadToEnd(); + } } else { @@ -389,15 +393,15 @@ namespace CMLeonOS return currentDirectory; } - char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' }; - foreach (char c in invalidChars) - { - if (path.Contains(c.ToString())) - { - Console.WriteLine($"Error: Invalid character in path: '{c}'"); - return currentDirectory; - } - } + //char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' }; + //foreach (char c in invalidChars) + //{ + // if (path.Contains(c.ToString())) + // { + // Console.WriteLine($"Error: Invalid character in path: '{c}'"); + // return currentDirectory; + // } + //} if (path.Contains("//") || path.Contains("\\\\")) { diff --git a/System/UserSystem.cs b/System/UserSystem.cs index 08c7f31..4a09492 100644 --- a/System/UserSystem.cs +++ b/System/UserSystem.cs @@ -55,7 +55,7 @@ namespace CMLeonOS private static bool ContainsInvalidChars(string input) { - char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' }; + char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\', ' ' }; foreach (char c in invalidChars) { if (input.Contains(c.ToString())) @@ -405,7 +405,7 @@ namespace CMLeonOS { CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.Red, global::System.ConsoleColor.Black); global::System.Console.SetCursorPosition(7, 24); - global::System.Console.Write("Username contains invalid characters: < > : \" | ? / \\ "); + global::System.Console.Write("Username contains invalid characters: < > : \" | ? * / \\ space"); CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black); global::System.Console.SetCursorPosition(7, 7); global::System.Console.Write("Username: "); diff --git a/editor/Nano.cs b/editor/Nano.cs index 4fe9112..a4f666d 100644 --- a/editor/Nano.cs +++ b/editor/Nano.cs @@ -47,15 +47,22 @@ namespace CMLeonOS if (value != null && fileSystem != null) { - string fullPath = fileSystem.GetFullPath(value); - - if (System.IO.File.Exists(fullPath)) + try { + string fullPath = fileSystem.GetFullPath(value); string text = fileSystem.ReadFile(fullPath); - text = text.Replace("\r\n", "\n"); - lines.AddRange(text.Split('\n')); + + if (!string.IsNullOrEmpty(text)) + { + text = text.Replace("\r\n", "\n"); + lines.AddRange(text.Split('\n')); + } + else + { + lines.Add(string.Empty); + } } - else + catch { lines.Add(string.Empty); }