Fixed typo with project directory

- Renamed IsFSActive to isFSEnabled
This commit is contained in:
Tony Bark 2023-01-07 10:44:51 -05:00
parent 81bf203b6f
commit 7b56b93edd
10 changed files with 120 additions and 70 deletions

View file

@ -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

View file

@ -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

View file

@ -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.
/// </summary>
[SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")]
public static string BuildNumber = $"Build {BuildNumFromCommit}";
/// <summary>
/// Let's the system know that the file system is activated.
/// Let's the kernel know that the file system is activated.
/// </summary>
public static bool IsFSActive { get; set; } = false;
public static bool IsFSEnabled { get; set; } = false;
/// <summary>
/// Generates the build number from the commit hash.

View file

@ -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);
}
}
}
}

View file

@ -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);
}
}
}
}

View file

@ -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.";
/// <summary>
/// An instance of the CosmosVFS class, used for accessing the virtual file system
/// </summary>
static CosmosVFS fileSystem = new();
/// <summary>
/// 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);

View file

@ -5,6 +5,7 @@
<!--<RuntimeIdentifier>cosmos</RuntimeIdentifier>-->
<Platform>cosmos</Platform>
<SupportsX86Intrinsics>false</SupportsX86Intrinsics>
<Nullable>enable</Nullable>
<SelfContained>True</SelfContained>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>