From 34021cce51b5e42334913fabaec0c98dea712281 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Thu, 5 Feb 2026 20:42:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E5=85=A5=E7=B3=BB=E7=BB=9F=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=87=AA=E5=8A=A8=E8=BF=9B=E5=85=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/FileSystem.cs | 12 ++++++++++++ System/UserSystem.cs | 5 +++++ shell/Shell.cs | 23 ++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/System/FileSystem.cs b/System/FileSystem.cs index e72c797..9a86bc5 100644 --- a/System/FileSystem.cs +++ b/System/FileSystem.cs @@ -14,6 +14,18 @@ namespace CMLeonOS currentDirectory = @"0:\"; } + public FileSystem(string initialPath) + { + if (string.IsNullOrEmpty(initialPath)) + { + currentDirectory = @"0:\"; + } + else + { + currentDirectory = initialPath; + } + } + public string CurrentDirectory { get { return currentDirectory; } diff --git a/System/UserSystem.cs b/System/UserSystem.cs index a2bb656..ee1c38c 100644 --- a/System/UserSystem.cs +++ b/System/UserSystem.cs @@ -24,6 +24,11 @@ namespace CMLeonOS public bool fixmode = Kernel.FixMode; private User currentLoggedInUser; + public User CurrentLoggedInUser + { + get { return currentLoggedInUser; } + } + public void ShowError(string error) { Console.ForegroundColor = ConsoleColor.Red; diff --git a/shell/Shell.cs b/shell/Shell.cs index 26f1a1d..1b3b7df 100644 --- a/shell/Shell.cs +++ b/shell/Shell.cs @@ -54,11 +54,32 @@ namespace CMLeonOS public Shell(UserSystem userSystem) { this.userSystem = userSystem; - fileSystem = new FileSystem(); fixMode = Kernel.FixMode; envManager = EnvironmentVariableManager.Instance; Commands.AliasCommand.LoadAliases(); + + User currentUser = userSystem.CurrentLoggedInUser; + if (currentUser != null && !string.IsNullOrWhiteSpace(currentUser.Username)) + { + string userHomePath = $@"0:\user\{currentUser.Username}"; + try + { + if (!Directory.Exists(userHomePath)) + { + Directory.CreateDirectory(userHomePath); + } + fileSystem = new FileSystem(userHomePath); + } + catch (Exception) + { + fileSystem = new FileSystem(); + } + } + else + { + fileSystem = new FileSystem(); + } } public void Run()