Cosmos icon indicating copy to clipboard operation
Cosmos copied to clipboard

File System changes

Open Szymekk44 opened this issue 1 year ago • 3 comments

Partition Format function is now using enum as file system name (type).

Szymekk44 avatar Sep 21 '24 11:09 Szymekk44

If anyone was wondering why there is no enum, it's so that you can create your own file systems without having to changing and building again cosmos.

Szymekk44 avatar Sep 21 '24 15:09 Szymekk44

This needs more testing... You can already format partitions with labels: image and read/generate image Tho many things dont work. I think its because RootDirectory doesn't really exist image

Szymekk44 avatar Sep 21 '24 20:09 Szymekk44

Github dont break my code

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using Sys = Cosmos.System;

namespace TestingKernel
{
    public class Kernel : Sys.Kernel
    {
        public static CosmosVFS fs;
        protected override void BeforeRun()
        {
            Console.SetWindowSize(90, 30);
            Console.WriteLine("Welcome.");
            Kernel.fs = new Cosmos.System.FileSystem.CosmosVFS();
            Cosmos.System.FileSystem.VFS.VFSManager.RegisterVFS(fs);
        }

        protected override void Run()
        {
            Console.Write("Input: ");
            var input = Console.ReadLine();
            string[] inputs = input.Split(' ');
            if (inputs[0] == "format")
            {
                fs.Disks[0].Clear();
                if (fs.Disks[0].Partitions.Count == 0)
                    fs.Disks[0].CreatePartition(512);
                fs.Disks[0].FormatPartition(0, "FAT32", true, inputs[1]);
                Thread.Sleep(10000);
                Cosmos.System.Power.Reboot();
            }
            if (inputs[0] == "print")
            {
                Console.WriteLine(fs.Disks[0].Partitions[0].RootPath);
            }
            if (inputs[0] == "create")
            {
                try
                {
                    File.Create(fs.Disks[0].Partitions[0].RootPath + "Cosmos.txt");
                    Console.WriteLine(fs.Disks[0].Partitions[0].RootPath + "Cosmos.txt");
                    File.Create(fs.Disks[0].Partitions[0].RootPath + "Broom.txt");
                    Console.WriteLine(fs.Disks[0].Partitions[0].RootPath + "Broom.txt");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            if (inputs[0] == "dir")
            {
                try
                {
                    string[] files = Directory.GetFiles(fs.Disks[0].Partitions[0].RootPath);
                    Console.WriteLine(files.Length);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            if (inputs[0] == "gen")
            {
                try
                {
                    Directory.CreateDirectory(fs.Disks[0].Partitions[0].RootPath);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
            if (inputs[0] == "gen2")
            {
                try
                {
                    Directory.CreateDirectory(fs.Disks[0].Partitions[0].RootPath + "test");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }
    }
}

Szymekk44 avatar Sep 21 '24 20:09 Szymekk44