2023-01-06 19:03:07 -05:00
|
|
|
// I license this project under the BSD 3-Clause license.
|
2020-02-03 16:51:51 -05:00
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using Cosmos.System.FileSystem;
|
|
|
|
using Cosmos.System.FileSystem.VFS;
|
2022-12-25 18:27:57 -05:00
|
|
|
using Tomas.Common;
|
2020-02-03 16:51:51 -05:00
|
|
|
|
2023-01-06 19:34:09 -05:00
|
|
|
namespace Tomas.Kernel;
|
|
|
|
|
|
|
|
class TomFS
|
2020-02-03 16:51:51 -05:00
|
|
|
{
|
2023-01-06 19:34:09 -05:00
|
|
|
public const string ROOT_DIR = "0:\\";
|
|
|
|
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
|
2020-02-03 16:51:51 -05:00
|
|
|
|
2023-01-06 19:34:09 -05:00
|
|
|
public static void Initialize()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var fs = new CosmosVFS();
|
|
|
|
VFSManager.RegisterVFS(fs);
|
|
|
|
fs.CreateDirectory(SYSTEM_DIR);
|
|
|
|
Console.WriteLine("Creating system files.");
|
|
|
|
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
|
|
|
|
Console.WriteLine("Setting system preferences.");
|
2023-01-06 20:39:31 -05:00
|
|
|
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.BuildNumber}");
|
2023-01-06 19:34:09 -05:00
|
|
|
Console.WriteLine("File system loaded sucesfully.");
|
|
|
|
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
|
|
|
|
Console.WriteLine(intro);
|
2020-02-03 16:51:51 -05:00
|
|
|
|
2023-01-06 19:34:09 -05:00
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
Console.WriteLine("File system failed to load! Not all functions will work.");
|
|
|
|
}
|
|
|
|
}
|
2020-02-03 16:51:51 -05:00
|
|
|
|
2023-01-06 19:34:09 -05:00
|
|
|
public static string[] ListDirectories(string path)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var dirs = Directory.GetDirectories(path);
|
|
|
|
return dirs;
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
Console.WriteLine("Failed to find any directories.");
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
2020-02-03 16:51:51 -05:00
|
|
|
}
|