Cosmos/source/Cosmos.System2/FileSystem/DiskManager.cs
fanoI a52d7918a5 Created new DiskManager class with the required methods that DriveInfo does not have: Format, ChangeDriveLetter, CreatePartition.
- Only Format is implemented for now
- Modified Bochs configuration: increased IPS to 4'000'000 this makes it more faster
- Optimized ReadFatSector to allocate less
2018-07-22 14:58:57 +02:00

85 lines
2.5 KiB
C#

#define COSMOSDEBUG
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.System.FileSystem.VFS;
namespace Cosmos.System.FileSystem
{
public class DiskManager
{
public string Name {get; }
public DiskManager(string aDriveName)
{
if (aDriveName == null)
{
throw new ArgumentNullException(nameof(aDriveName));
}
if (!VFSManager.IsValidDriveId(aDriveName))
{
throw new ArgumentException("Argument must be drive identifier or root dir");
}
Global.mFileSystemDebugger.SendInternal($"Creating DriskManager for drive {aDriveName}");
Name = aDriveName;
}
public void Format(string aDriveFormat, bool aQuick = true)
{
/* For now we do the more easy thing: quick format of a drive with the same filesystem */
if (VFSManager.GetFileSystemType(Name) != aDriveFormat)
{
throw new NotImplementedException($"Formatting in {aDriveFormat} drive {Name} with Filesystem {VFSManager.GetFileSystemType(Name)} not yet supported");
}
if (aQuick == false)
{
throw new NotImplementedException("Slow format not implemented yet");
}
VFSManager.Format(Name, aDriveFormat, aQuick);
}
public void ChangeDriveLetter(string aNewName)
{
if (aNewName == null)
{
throw new ArgumentNullException(nameof(aNewName));
}
if (!VFSManager.IsValidDriveId(aNewName))
{
throw new ArgumentException("Argument must be drive identifier or root dir");
}
/*
* 1. Add new method in VFSManager to change identifier of a drive
* 2. Update 'Name' to be 'aNewName'
*/
throw new NotImplementedException("ChangeDriveLetter");
}
public void CreatePartion(long start, long end)
{
if (start < 0)
{
throw new ArgumentOutOfRangeException(nameof(start));
}
if (end < 0)
{
throw new ArgumentOutOfRangeException(nameof(start));
}
if (end <= start)
{
throw new ArgumentException("end is <= start");
}
throw new NotImplementedException("CreatePartion");
}
}
}