mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 05:52:11 +00:00
Fixed Newobj for string with length parameter.
Minor changes in debugging and FAT test messages. Removed useless "if" in FAT, previously added by me.
This commit is contained in:
parent
4b67c02f26
commit
2c3ae6221d
6 changed files with 43 additions and 17 deletions
|
|
@ -461,7 +461,7 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
mDebugger.Send("");
|
||||
|
||||
//
|
||||
mDebugger.Send("Get files:");
|
||||
mDebugger.Send("START TEST: Get files:");
|
||||
var xFiles = Directory.GetFiles(@"0:\");
|
||||
mDebugger.Send("Found " + xFiles.Length + " files.");
|
||||
if (xFiles.Length > 0)
|
||||
|
|
@ -478,7 +478,7 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
mDebugger.Send("");
|
||||
|
||||
//
|
||||
mDebugger.Send("Get directories:");
|
||||
mDebugger.Send("START TEST: Get directories:");
|
||||
var xDirectories = Directory.GetDirectories(@"0:\");
|
||||
mDebugger.Send("Found " + xDirectories.Length + " directories.");
|
||||
if (xDirectories.Length > 0)
|
||||
|
|
@ -495,14 +495,14 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
mDebugger.Send("");
|
||||
|
||||
//
|
||||
mDebugger.Send("Directory exist check:");
|
||||
mDebugger.Send("START TEST: Directory exist check:");
|
||||
var xTest = Directory.Exists(@"0:\test");
|
||||
Assert.IsTrue(xTest, "Folder does not exist!");
|
||||
mDebugger.Send("END TEST");
|
||||
|
||||
mDebugger.Send("");
|
||||
|
||||
mDebugger.Send("START TEST");
|
||||
mDebugger.Send("START TEST: Create Directory");
|
||||
var xDirectory = Directory.CreateDirectory(@"0:\test2");
|
||||
Assert.IsTrue(xDirectory != null, "Directory.CreateDirectory failed: Directory is null");
|
||||
bool xExists = Directory.Exists(@"0:\test2");
|
||||
|
|
|
|||
|
|
@ -106,6 +106,5 @@ namespace Cosmos.Common.Extensions
|
|||
}
|
||||
return new string(xChars);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
&& xParams[2].ParameterType == typeof(int))
|
||||
{
|
||||
xHasCalcSize = true;
|
||||
XS.Set(EAX, ESP, sourceDisplacement: 4, sourceIsIndirect: true);
|
||||
XS.Set(EAX, ESP, sourceIsIndirect: true);
|
||||
XS.ShiftLeft(EAX, 1);
|
||||
XS.Push(EAX);
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ namespace Cosmos.IL2CPU.X86.IL
|
|||
&& xParams[1].ParameterType == typeof(int))
|
||||
{
|
||||
xHasCalcSize = true;
|
||||
XS.Set(EAX, ESP, sourceDisplacement: 4, sourceIsIndirect: true);
|
||||
XS.Set(EAX, ESP, sourceIsIndirect: true);
|
||||
XS.ShiftLeft(EAX, 1);
|
||||
XS.Push(EAX);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,13 +36,19 @@ namespace Cosmos.System.Plugs.System.IO
|
|||
Global.mFileSystemDebugger.SendInternal(aPath);
|
||||
|
||||
aStorage = VFSManager.GetDirectory(aPath);
|
||||
|
||||
if (aStorage == null)
|
||||
{
|
||||
throw new NullReferenceException("Failed to create DirectoryInfo: Directory '" + aPath + "' doesn't exist");
|
||||
}
|
||||
|
||||
aFullPath = aStorage.mFullPath;
|
||||
aName = aStorage.mName;
|
||||
}
|
||||
|
||||
public static string get_Name(DirectoryInfo aThis)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal($"DirectoryInfo.get_Name : Nane = {aThis}");
|
||||
Global.mFileSystemDebugger.SendInternal($"DirectoryInfo.get_Name : Name = {aThis}");
|
||||
return aThis.ToString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ namespace Cosmos.System.FileSystem
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("CosmosVFS.GetDirectory - DoGetDirectoryEntry failed, returning null. aPath = " + aPath);
|
||||
return null;
|
||||
}
|
||||
throw new Exception(aPath + " was found, but is not a directory.");
|
||||
|
|
@ -259,6 +260,7 @@ namespace Cosmos.System.FileSystem
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("CosmosVFS.GetFile - DoGetDirectoryEntry failed, returning null. aPath = " + aPath);
|
||||
return null;
|
||||
}
|
||||
throw new Exception(aPath + " was found, but is not a file.");
|
||||
|
|
|
|||
|
|
@ -140,14 +140,19 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
}
|
||||
|
||||
string xNameString = new string(xName);
|
||||
|
||||
SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.ShortName, xNameString);
|
||||
|
||||
if (mEntryType == DirectoryEntryTypeEnum.Directory)
|
||||
{
|
||||
SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.Attributes, FatDirectoryEntryAttributeConsts.Directory);
|
||||
}
|
||||
|
||||
SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.FirstClusterHigh, (uint)(mFirstClusterNum >> 16));
|
||||
SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata.FirstClusterLow, (uint)(mFirstClusterNum & 0xFFFF));
|
||||
|
||||
byte[] xData = GetDirectoryEntryData();
|
||||
|
||||
SetDirectoryEntryData(xData);
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +177,9 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
Global.mFileSystemDebugger.SendInternal(xEntryHeaderDataOffset);
|
||||
|
||||
var xNewEntry = new FatDirectoryEntry((FatFileSystem)mFileSystem, this, xFullPath, aName, 0, xFirstCluster, xEntryHeaderDataOffset, aType);
|
||||
|
||||
xNewEntry.AllocateDirectoryEntry();
|
||||
|
||||
return xNewEntry;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException(nameof(aType), "Unknown directory entry type.");
|
||||
|
|
@ -205,21 +212,25 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
if (xAttrib == FatDirectoryEntryAttributeConsts.LongName)
|
||||
{
|
||||
byte xType = xData[i + 12];
|
||||
|
||||
if (xStatus == FatDirectoryEntryAttributeConsts.UnusedOrDeletedEntry)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("<DELETED> : Attrib = " + xAttrib + ", Status = " + xStatus);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (xType == 0)
|
||||
{
|
||||
if ((xStatus & 0x40) > 0)
|
||||
{
|
||||
xLongName = "";
|
||||
}
|
||||
|
||||
//TODO: Check LDIR_Ord for ordering and throw exception
|
||||
// if entries are found out of order.
|
||||
// Also save buffer and only copy name if a end Ord marker is found.
|
||||
string xLongPart = xData.GetUtf16String(i + 1, 5);
|
||||
|
||||
// We have to check the length because 0xFFFF is a valid Unicode codepoint.
|
||||
// So we only want to stop if the 0xFFFF is AFTER a 0x0000. We can determin
|
||||
// this by also looking at the length. Since we short circuit the or, the length
|
||||
|
|
@ -227,11 +238,13 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
if (xData.ToUInt16(i + 14) != 0xFFFF || xLongPart.Length == 5)
|
||||
{
|
||||
xLongPart = xLongPart + xData.GetUtf16String(i + 14, 6);
|
||||
|
||||
if (xData.ToUInt16(i + 28) != 0xFFFF || xLongPart.Length == 11)
|
||||
{
|
||||
xLongPart = xLongPart + xData.GetUtf16String(i + 28, 2);
|
||||
}
|
||||
}
|
||||
|
||||
xLongName = xLongPart + xLongName;
|
||||
xLongPart = null;
|
||||
//TODO: LDIR_Chksum
|
||||
|
|
@ -240,11 +253,13 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
else
|
||||
{
|
||||
xName = xLongName;
|
||||
|
||||
if (xStatus == 0x00)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("<EOF> : Attrib = " + xAttrib + ", Status = " + xStatus);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (xStatus)
|
||||
{
|
||||
case 0x05:
|
||||
|
|
@ -266,6 +281,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
|
||||
//If there are trailing periods
|
||||
int nameIndex = xName.Length - 1;
|
||||
|
||||
if (xName[nameIndex] == '.')
|
||||
{
|
||||
//Search backwards till we find the first non-period character
|
||||
|
|
@ -279,6 +295,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
//Substring to remove the periods
|
||||
xName = xName.Substring(0, nameIndex + 1);
|
||||
}
|
||||
|
||||
xLongName = "";
|
||||
}
|
||||
else
|
||||
|
|
@ -286,6 +303,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
string xEntry = xData.GetAsciiString(i, 11);
|
||||
xName = xEntry.Substring(0, 8).TrimEnd();
|
||||
string xExt = xEntry.Substring(8, 3).TrimEnd();
|
||||
|
||||
if (xExt.Length > 0)
|
||||
{
|
||||
xName = xName + "." + xExt;
|
||||
|
|
@ -298,11 +316,8 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
uint xFirstCluster = (uint)(xData.ToUInt16(i + 20) << 16 | xData.ToUInt16(i + 26));
|
||||
|
||||
int xTest = xAttrib & (FatDirectoryEntryAttributeConsts.Directory | FatDirectoryEntryAttributeConsts.VolumeID);
|
||||
if (xStatus == FatDirectoryEntryAttributeConsts.UnusedOrDeletedEntry)
|
||||
{
|
||||
// deleted file
|
||||
}
|
||||
else if (xAttrib == FatDirectoryEntryAttributeConsts.LongName)
|
||||
|
||||
if (xAttrib == FatDirectoryEntryAttributeConsts.LongName)
|
||||
{
|
||||
// skip adding, as it's a LongFileName entry, meaning the next normal entry is the item with the name.
|
||||
//Global.mFileSystemDebugger.SendInternal($"Entry was a Long FileName entry. Current LongName = '{xLongName}'");
|
||||
|
|
@ -310,10 +325,12 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
else if (xTest == 0)
|
||||
{
|
||||
uint xSize = xData.ToUInt32(i + 28);
|
||||
|
||||
if (xSize == 0 && xName.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string xFullPath = Path.Combine(mFullPath, xName);
|
||||
var xEntry = new FatDirectoryEntry(((FatFileSystem)mFileSystem), xParent, xFullPath, xName, xSize, xFirstCluster, i, DirectoryEntryTypeEnum.File);
|
||||
xResult.Add(xEntry);
|
||||
|
|
@ -419,7 +436,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
uint offset = mEntryHeaderDataOffset + aEntryMetadata.DataOffset;
|
||||
Array.Copy(xValue, 0, xData, offset, aEntryMetadata.DataLength);
|
||||
((FatDirectoryEntry)mParent).SetDirectoryEntryData(xData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -445,7 +462,7 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
Global.mFileSystemDebugger.SendInternal(offset);
|
||||
Array.Copy(xValue, 0, xData, offset, aEntryMetadata.DataLength);
|
||||
((FatDirectoryEntry)mParent).SetDirectoryEntryData(xData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -464,10 +481,12 @@ namespace Cosmos.System.FileSystem.FAT.Listing
|
|||
{
|
||||
var xValue = new byte[aEntryMetadata.DataLength];
|
||||
xValue = aValue.GetUtf8Bytes(0, aEntryMetadata.DataLength);
|
||||
|
||||
uint offset = mEntryHeaderDataOffset + aEntryMetadata.DataOffset;
|
||||
Array.Copy(xValue, 0, xData, offset, aEntryMetadata.DataLength);
|
||||
|
||||
((FatDirectoryEntry)mParent).SetDirectoryEntryData(xData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue