Merge pull request #477 from jp2masa/Bugfixes

Fix Newobj for string and minor changes
This commit is contained in:
Charles Betros 2016-09-29 15:14:37 -05:00 committed by GitHub
commit bf3820d914
7 changed files with 40 additions and 20 deletions

View file

@ -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");

View file

@ -16,8 +16,8 @@ namespace Cosmos.TestRunner.Core
yield return typeof(Cosmos.Compiler.Tests.LinqTests.Kernel);
yield return typeof(Cosmos.Compiler.Tests.MethodTests.Kernel);
yield return typeof(Cosmos.Kernel.Tests.IO.Kernel);
yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel);
//yield return typeof(Cosmos.Kernel.Tests.Fat.Kernel);
//yield return typeof(Cosmos.Compiler.Tests.Encryption.Kernel);
//yield return typeof(FrotzKernel.Kernel);
}

View file

@ -106,6 +106,5 @@ namespace Cosmos.Common.Extensions
}
return new string(xChars);
}
}
}
}

View file

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

View file

@ -36,13 +36,13 @@ namespace Cosmos.System.Plugs.System.IO
Global.mFileSystemDebugger.SendInternal(aPath);
aStorage = VFSManager.GetDirectory(aPath);
aFullPath = aStorage.mFullPath;
aName = aStorage.mName;
aFullPath = aPath;
aName = Path.GetFileName(aPath);
}
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();
}

View file

@ -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.");

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