Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File System changes #3085

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

Szymekk44
Copy link
Contributor

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

@Szymekk44
Copy link
Contributor Author

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 Szymekk44 marked this pull request as draft September 21, 2024 20:10
@Szymekk44
Copy link
Contributor Author

Szymekk44 commented Sep 21, 2024

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant