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