mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +00:00
File system fixes and code cleanup.
This commit is contained in:
parent
daa40d38e2
commit
4a801eb167
5 changed files with 42 additions and 34 deletions
|
|
@ -410,7 +410,7 @@ namespace Cosmos.System.FileSystem
|
|||
if (fs.IsType(mPartitions[i]))
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal($"Partion {i} has a {fs.Name} filesystem");
|
||||
mFileSystems.Add(new FatFileSystem(mPartitions[i], xRootPath, xSize));
|
||||
mFileSystems.Add(fs.Create(mPartitions[i], xRootPath, xSize));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -543,23 +543,6 @@ namespace Cosmos.System.FileSystem.FAT
|
|||
}
|
||||
}
|
||||
|
||||
public static bool IsDeviceFat(Partition aDevice)
|
||||
{
|
||||
if (aDevice == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(aDevice));
|
||||
}
|
||||
|
||||
var xBPB = aDevice.NewBlockArray(1);
|
||||
aDevice.ReadBlock(0UL, 1U, xBPB);
|
||||
ushort xSig = BitConverter.ToUInt16(xBPB, 510);
|
||||
if (xSig != 0xAA55)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DisplayFileSystemInfo()
|
||||
{
|
||||
global::System.Console.WriteLine("-------File System--------");
|
||||
|
|
|
|||
|
|
@ -155,7 +155,10 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
string xShortName = aName;
|
||||
uint[] xDirectoryEntriesToAllocate = null;
|
||||
|
||||
//Stack corruption, just delete everything from this until commented if when it's fixed
|
||||
// Stack corruption, just delete everything from this until commented if when it's fixed
|
||||
//
|
||||
// https://github.com/CosmosOS/IL2CPU/issues/8
|
||||
//
|
||||
var x1 = aEntryType == DirectoryEntryTypeEnum.File;
|
||||
var x2 = aName.Contains(".");
|
||||
var x3 = x2 ? aName.Substring(0, aName.LastIndexOf('.')).Contains(".") : false;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
using Cosmos.HAL.BlockDevice;
|
||||
using System;
|
||||
|
||||
using Cosmos.HAL.BlockDevice;
|
||||
using Cosmos.System.FileSystem.FAT;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.System.FileSystem
|
||||
{
|
||||
public class FatFileSystemFactory : FileSystemFactory
|
||||
{
|
||||
public override string Name { get => "FAT"; }
|
||||
public override string Name => "FAT";
|
||||
|
||||
public override bool IsType(Partition aDevice)
|
||||
{
|
||||
if (aDevice == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(aDevice));
|
||||
}
|
||||
|
||||
var xBPB = aDevice.NewBlockArray(1);
|
||||
aDevice.ReadBlock(0UL, 1U, xBPB);
|
||||
|
||||
var xSig = BitConverter.ToUInt16(xBPB, 510);
|
||||
return xSig == 0xAA55;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FatFileSystem"/> class.
|
||||
|
|
@ -17,7 +30,5 @@ namespace Cosmos.System.FileSystem
|
|||
/// <param name="aRootPath">The root path.</param>
|
||||
/// <exception cref="Exception">FAT signature not found.</exception>
|
||||
public override FileSystem Create(Partition aDevice, string aRootPath, long aSize) => new FatFileSystem(aDevice, aRootPath, aSize);
|
||||
|
||||
public override bool IsType(Partition aDevice) => FatFileSystem.IsDeviceFat(aDevice);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,27 @@
|
|||
using Cosmos.HAL.BlockDevice;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.System.FileSystem
|
||||
{
|
||||
public class FileSystemFactory
|
||||
public abstract class FileSystemFactory
|
||||
{
|
||||
public virtual string Name { get; private set; }
|
||||
/// <summary>
|
||||
/// The name of the file system.
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
public virtual FileSystem Create(Partition aDevice, string aRootPath, long aSize) => null;
|
||||
|
||||
public virtual bool IsType(Partition aDevice) => false;
|
||||
/// <summary>
|
||||
/// Checks if the file system can handle the partition.
|
||||
/// </summary>
|
||||
/// <param name="aDevice">The partition.</param>
|
||||
/// <returns>Returns true if the file system can handle the partition, false otherwise.</returns>
|
||||
public abstract bool IsType(Partition aDevice);
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FileSystem"/> object for the given partition, root path, and size.
|
||||
/// </summary>
|
||||
/// <param name="aDevice">The partition.</param>
|
||||
/// <param name="aRootPath">The root path.</param>
|
||||
/// <param name="aSize">The size, in MB.</param>
|
||||
/// <returns></returns>
|
||||
public abstract FileSystem Create(Partition aDevice, string aRootPath, long aSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue