diff --git a/src/.editorconfig b/src/.editorconfig
index 7868c26..ebdac3a 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -13,6 +13,8 @@ indent_style = space
indent_size = 4
insert_final_newline = false
trim_trailing_whitespace = true
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+tab_width = 4
# C# files
[*.cs]
@@ -50,7 +52,7 @@ dotnet_style_predefined_type_for_member_access = true:suggestion
# Use camel_case for private or internal constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
-dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
+dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
@@ -62,7 +64,7 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# internal and private fields should be _camel_case
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
-dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
+dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
@@ -122,3 +124,9 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
+csharp_using_directive_placement = outside_namespace:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_prefer_braces = when_multiline:silent
+csharp_style_namespace_declarations = file_scoped:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
diff --git a/src/TOMAS.sln b/src/TOMAS.sln
index 5fff92d..5a713b9 100644
--- a/src/TOMAS.sln
+++ b/src/TOMAS.sln
@@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Interface", "Tomas.In
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Terminal", "Tomas.Terminal\Tomas.Terminal.csproj", "{49E67E55-F9D2-419A-8097-38F39E98A95E}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernel", "Tomas.Kernal\Tomas.Kernel.csproj", "{20750C95-A3C7-4958-BA9F-56E4C3BD0293}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernel", "Tomas.Kernel\Tomas.Kernel.csproj", "{B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,10 +39,10 @@ Global
{49E67E55-F9D2-419A-8097-38F39E98A95E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49E67E55-F9D2-419A-8097-38F39E98A95E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49E67E55-F9D2-419A-8097-38F39E98A95E}.Release|Any CPU.Build.0 = Release|Any CPU
- {20750C95-A3C7-4958-BA9F-56E4C3BD0293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {20750C95-A3C7-4958-BA9F-56E4C3BD0293}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {20750C95-A3C7-4958-BA9F-56E4C3BD0293}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {20750C95-A3C7-4958-BA9F-56E4C3BD0293}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B70BDFD5-64BA-4FCE-A00F-DDD209C2C0FB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Tomas.Common/SysMeta.cs b/src/Tomas.Common/SysMeta.cs
index 79ffd67..80c9505 100644
--- a/src/Tomas.Common/SysMeta.cs
+++ b/src/Tomas.Common/SysMeta.cs
@@ -26,13 +26,12 @@ public struct SysMeta
/// The build number is a 6-digit number, with the first 3 digits being the first 3 digits of the commit hash
/// converted to a uint, and the last 3 digits being the last 3 digits of the commit hash converted to a uint.
///
- [SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")]
public static string BuildNumber = $"Build {BuildNumFromCommit}";
///
- /// Let's the system know that the file system is activated.
+ /// Let's the kernel know that the file system is activated.
///
- public static bool IsFSActive { get; set; } = false;
+ public static bool IsFSEnabled { get; set; } = false;
///
/// Generates the build number from the commit hash.
diff --git a/src/Tomas.Kernal/Kernel.cs b/src/Tomas.Kernal/Kernel.cs
deleted file mode 100644
index e5f4150..0000000
--- a/src/Tomas.Kernal/Kernel.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// I license this project under the BSD 3-Clause license.
-// See the LICENSE file in the project root for more information.
-
-namespace Tomas.Kernel;
-
-public class Kernel : Os.Kernel
-{
-
- protected override void BeforeRun()
- {
- SysFS.Initialize();
-
- if (!SysMeta.IsFSActive)
- Console.WriteLine($"{SysMeta.NAME} booted with errors.");
- else
- Console.WriteLine($"{SysMeta.NAME} booted successfully.");
- }
-
- protected override void Run()
- {
- while (true)
- {
- var shell = new Shell();
- var command = shell.ReadLine;
- var programs = shell.Programs;
-
- if (!programs.TryGetValue(command, out var program))
- {
- Console.WriteLine("Command Not Found.");
- continue;
- }
-
- try
- {
- var start = program.Run(shell);
- switch (start)
- {
- case true:
- continue;
- case false:
- Console.WriteLine("Program closed unexpectedly.");
- continue;
- }
- }
- catch (Exception err)
- {
- Console.WriteLine(err.Message);
- }
- }
- }
-}
diff --git a/src/Tomas.Kernal/GlobalUsing.cs b/src/Tomas.Kernel/GlobalUsing.cs
similarity index 100%
rename from src/Tomas.Kernal/GlobalUsing.cs
rename to src/Tomas.Kernel/GlobalUsing.cs
diff --git a/src/Tomas.Kernel/Kernel.cs b/src/Tomas.Kernel/Kernel.cs
new file mode 100644
index 0000000..9ce08b6
--- /dev/null
+++ b/src/Tomas.Kernel/Kernel.cs
@@ -0,0 +1,70 @@
+// I license this project under the BSD 3-Clause license.
+// See the LICENSE file in the project root for more information.
+
+namespace Tomas.Kernel;
+
+public class Kernel : Os.Kernel
+{
+ // This method is called before the Run method
+ protected override void BeforeRun()
+ {
+ // Initialize the file system
+ SysFS.Initialize();
+
+ // If the file system is not enabled, print an error message indicating that the system booted with errors
+ if (!SysMeta.IsFSEnabled)
+ Console.WriteLine($"{SysMeta.NAME} booted with errors.");
+ // If the file system is enabled, print a message indicating that the system booted successfully
+ else
+ Console.WriteLine($"{SysMeta.NAME} booted successfully.");
+ }
+
+ // This method is the main loop of the kernel, which handles input and runs programs
+ protected override void Run()
+ {
+ // Run the loop indefinitely
+ while (true)
+ {
+ // Create a new instance of the Shell class
+ var shell = new Shell();
+
+ // Read a line of input from the user
+ var command = shell.ReadLine;
+
+ // Get the dictionary of programs from the shell
+ var programs = shell.Programs;
+
+ // If the command is not a key in the dictionary of programs, print an error message
+ // and continue to the next iteration of the loop
+ if (!programs.TryGetValue(command, out var program))
+ {
+ Console.WriteLine("Command Not Found.");
+ continue;
+ }
+
+ // Try to run the program and handle any exceptions that may be thrown
+ try
+ {
+ // Run the program and store the returned value in the 'start' variable
+ var start = program.Run(shell);
+
+ // Check the value of 'start' and take the appropriate action
+ switch (start)
+ {
+ case true:
+ // If 'start' is true, continue to the next iteration of the loop
+ continue;
+ case false:
+ // If 'start' is false, print an error message and continue to the next iteration of the loop
+ Console.WriteLine("Program closed unexpectedly.");
+ continue;
+ }
+ }
+ catch (Exception err)
+ {
+ // If an exception is caught, print the error message and continue to the next iteration of the loop
+ Console.WriteLine(err.Message);
+ }
+ }
+ }
+}
diff --git a/src/Tomas.Kernal/Programs/About.cs b/src/Tomas.Kernel/Programs/About.cs
similarity index 100%
rename from src/Tomas.Kernal/Programs/About.cs
rename to src/Tomas.Kernel/Programs/About.cs
diff --git a/src/Tomas.Kernal/Shell.cs b/src/Tomas.Kernel/Shell.cs
similarity index 100%
rename from src/Tomas.Kernal/Shell.cs
rename to src/Tomas.Kernel/Shell.cs
diff --git a/src/Tomas.Kernal/SysFS.cs b/src/Tomas.Kernel/SysFS.cs
similarity index 73%
rename from src/Tomas.Kernal/SysFS.cs
rename to src/Tomas.Kernel/SysFS.cs
index 56f4d58..73118b9 100644
--- a/src/Tomas.Kernal/SysFS.cs
+++ b/src/Tomas.Kernel/SysFS.cs
@@ -12,8 +12,12 @@ static class SysFS
static string LOG_FILE = $"{SYSTEM_DIR}system.log";
- // An instance of the CosmosVFS class, used for accessing the virtual file system
- static readonly CosmosVFS _fs = new();
+ const string FS_ERROR = "File system disabled.";
+
+ ///
+ /// An instance of the CosmosVFS class, used for accessing the virtual file system
+ ///
+ static CosmosVFS fileSystem = new();
///
/// Initializes the file system by creating the system directory and sysinfo.txt file
@@ -26,20 +30,25 @@ static class SysFS
var createSysFiles = "Creating system files.";
var setSysPref = "Writing system info.";
var fsSuccess = "File system succesfully initialized.";
+ var sysInfoFile = "sysinfo.txt";
// Register the CosmosVFS instance as the virtual file system
- VFSManager.RegisterVFS(_fs);
+ VFSManager.RegisterVFS(fileSystem);
// Create the system directory
- _fs.CreateDirectory(SYSTEM_DIR);
+ if (!Directory.Exists(SYSTEM_DIR))
+ fileSystem.CreateDirectory(SYSTEM_DIR);
- _fs.CreateFile($"{SYSTEM_DIR}{LOG_FILE}");
+ // Create the system.log file in the system directory
+ if (!File.Exists($"{SYSTEM_DIR}{LOG_FILE}"))
+ fileSystem.CreateFile($"{SYSTEM_DIR}{LOG_FILE}");
Console.WriteLine(createSysFiles);
File.AppendAllText(LOG_FILE, createSysFiles);
// Create the sysinfo.txt file in the system directory
- _fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
+ if (!File.Exists($"{SYSTEM_DIR}{sysInfoFile}"))
+ fileSystem.CreateFile($"{SYSTEM_DIR}{sysInfoFile}");
Console.WriteLine(setSysPref);
@@ -52,7 +61,7 @@ static class SysFS
File.AppendAllText(LOG_FILE, fsSuccess);
// Set the IsFSActive property of the SysMeta class to true
- SysMeta.IsFSActive = true;
+ SysMeta.IsFSEnabled = true;
// Read the contents of the sysinfo.txt file and print it to the console
var systemInfo = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
@@ -74,8 +83,13 @@ static class SysFS
{
try
{
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
+
// Create the directory using the CosmosVFS instance
- _fs.CreateDirectory($"{ROOT_DIR}\\{directory}");
+ if (!Directory.Exists($"{ROOT_DIR}\\{directory}"))
+ fileSystem.CreateDirectory($"{ROOT_DIR}\\{directory}");
}
catch (IOException err)
{
@@ -94,8 +108,13 @@ static class SysFS
{
try
{
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
+
// Create the file using the CosmosVFS instance
- _fs.CreateFile($"{ROOT_DIR}\\{path}\\{file}");
+ if (!File.Exists($"{ROOT_DIR}\\{path}\\{file}"))
+ fileSystem.CreateFile($"{ROOT_DIR}\\{path}\\{file}");
}
catch (IOException err)
{
@@ -114,6 +133,10 @@ static class SysFS
{
try
{
+ // If file system isn't enabeld, throw exception
+ if (!SysMeta.IsFSEnabled)
+ throw new IOException(FS_ERROR);
+
// Get the directories in the specified path using the Directory.GetDirectories method
var dirs = Directory.GetDirectories(path);
diff --git a/src/Tomas.Kernal/Tomas.Kernel.csproj b/src/Tomas.Kernel/Tomas.Kernel.csproj
similarity index 97%
rename from src/Tomas.Kernal/Tomas.Kernel.csproj
rename to src/Tomas.Kernel/Tomas.Kernel.csproj
index f747da9..eeb902b 100644
--- a/src/Tomas.Kernal/Tomas.Kernel.csproj
+++ b/src/Tomas.Kernel/Tomas.Kernel.csproj
@@ -5,6 +5,7 @@
cosmos
false
+ enable
True
enable