mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +00:00
Reading almost fixed.
This commit is contained in:
parent
6e2dda177f
commit
8e35d79602
17 changed files with 113 additions and 45 deletions
|
|
@ -46,6 +46,7 @@
|
|||
<Compile Include="System\Collections\Generic\ListTest.cs" />
|
||||
<Compile Include="System\Collections\Generic\QueueTest.cs" />
|
||||
<Compile Include="System\DelegatesTest.cs" />
|
||||
<Compile Include="System\StringTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Cosmos.TestRunner.TestController\Cosmos.TestRunner.TestController.csproj">
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace Cosmos.Compiler.Tests.Bcl
|
|||
|
||||
protected override void Run()
|
||||
{
|
||||
System.StringTest.Execute();
|
||||
System.Collections.Generic.ListTest.Execute();
|
||||
System.Collections.Generic.QueueTest.Execute();
|
||||
System.DelegatesTest.Execute();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
|||
{
|
||||
mCount += 2;
|
||||
}
|
||||
|
||||
|
||||
public static void Execute()
|
||||
{
|
||||
TestDelegateWithoutArguments();
|
||||
|
|
@ -49,7 +49,7 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
|||
{
|
||||
mCount += number;
|
||||
}
|
||||
|
||||
|
||||
private static void TestDelegateWithArguments()
|
||||
{
|
||||
mCount = 0;
|
||||
|
|
@ -64,4 +64,4 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
|||
Assert.AreEqual(3, mCount, "After calling delegate second time, Count != 3");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs
Normal file
16
Tests/Cosmos.Compiler.Tests.Bcl/System/StringTest.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cosmos.TestRunner;
|
||||
|
||||
namespace Cosmos.Compiler.Tests.Bcl.System
|
||||
{
|
||||
public static class StringTest
|
||||
{
|
||||
public static void Execute()
|
||||
{
|
||||
Assert.IsTrue(("a" + "b") == "ab", "concatting 2 string using + doesn't work");
|
||||
Assert.IsTrue(("a" + 'b') == "ab", "concatting 1 string and 1 character doesn't work");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,21 +25,22 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
protected override void Run()
|
||||
{
|
||||
mDebugger.Send("Run");
|
||||
var xRoot = Path.GetPathRoot(@"0:\test");
|
||||
bool xTest = Directory.Exists("0:\\test");
|
||||
Console.WriteLine("After test");
|
||||
Assert.IsTrue(xTest, "Folder does not exist!");
|
||||
//var xRoot = Path.GetPathRoot(@"0:\test");
|
||||
//bool xTest = Directory.Exists("0:\\test");
|
||||
//Console.WriteLine("After test");
|
||||
//Assert.IsTrue(xTest, "Folder does not exist!");
|
||||
|
||||
Console.WriteLine("Folder exists!");
|
||||
xTest = Directory.Exists("0:\\test\\DirInTest");
|
||||
Assert.IsTrue(xTest, "Subfolder doesn't exist!");
|
||||
//Console.WriteLine("Folder exists!");
|
||||
//xTest = Directory.Exists("0:\\test\\DirInTest");
|
||||
//Assert.IsTrue(xTest, "Subfolder doesn't exist!");
|
||||
|
||||
xTest = File.Exists(@"0:\KudzU.txt");
|
||||
Assert.IsTrue(xTest, @"\Kudzu.txt not found!");
|
||||
//var xTest = File.Exists(@"0:\Kudzu.txt");
|
||||
//Assert.IsTrue(xTest, @"\Kudzu.txt not found!");
|
||||
|
||||
Console.WriteLine("Kudzu.txt found!");
|
||||
Console.Write("File contents of Kudzu.txt: ");
|
||||
Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt"));
|
||||
mDebugger.Send("File contents of Kudzu.txt: ");
|
||||
var xContents = File.ReadAllText(@"0:\Kudzu.txt");
|
||||
mDebugger.Send("Contents retrieved");
|
||||
mDebugger.Send(xContents);
|
||||
// File.WriteAllText(@"0:\Kudzu.txt", "Test FAT write.");
|
||||
// Console.WriteLine(File.ReadAllText(@"0:\Kudzu.txt"));
|
||||
|
||||
|
|
@ -57,4 +58,4 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,27 +19,29 @@ namespace Cosmos.TestRunner.Console
|
|||
|
||||
DefaultEngineConfiguration.Apply(xEngine);
|
||||
|
||||
var xOutputXml = new OutputHandlerXml();
|
||||
xEngine.OutputHandler = new MultiplexingOutputHandler(
|
||||
xOutputXml,
|
||||
new OutputHandlerFullConsole());
|
||||
//var xOutputXml = new OutputHandlerXml();
|
||||
//xEngine.OutputHandler = new MultiplexingOutputHandler(
|
||||
// xOutputXml,
|
||||
// new OutputHandlerFullConsole());
|
||||
|
||||
xEngine.OutputHandler = new OutputHandlerFullConsole();
|
||||
|
||||
xEngine.Execute();
|
||||
|
||||
global::System.Console.WriteLine("Do you want to save test run details?");
|
||||
global::System.Console.Write("Type yes, or nothing to just exit: ");
|
||||
var xResult = global::System.Console.ReadLine();
|
||||
if (xResult != null && xResult.Trim().Equals("yes", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var xSaveDialog = new SaveFileDialog();
|
||||
xSaveDialog.Filter = "XML documents|*.xml";
|
||||
if (xSaveDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//if (xResult != null && xResult.Trim().Equals("yes", StringComparison.OrdinalIgnoreCase))
|
||||
//{
|
||||
// var xSaveDialog = new SaveFileDialog();
|
||||
// xSaveDialog.Filter = "XML documents|*.xml";
|
||||
// if (xSaveDialog.ShowDialog() != DialogResult.OK)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
xOutputXml.SaveToFile(xSaveDialog.FileName);
|
||||
}
|
||||
// xOutputXml.SaveToFile(xSaveDialog.FileName);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
source/Cosmos.Common/.editorconfig
Normal file
2
source/Cosmos.Common/.editorconfig
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[Extensions/ByteConverter.cs]
|
||||
indent_size = 2
|
||||
|
|
@ -85,8 +85,15 @@
|
|||
<Compile Include="RingAttribute.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include=".editorconfig" />
|
||||
<None Include="Cosmos.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Cosmos.Debug.Kernel\Cosmos.Debug.Kernel.csproj">
|
||||
<Project>{61607F1E-58F9-41CF-972F-128384F3E115}</Project>
|
||||
<Name>Cosmos.Debug.Kernel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Debug.Kernel;
|
||||
|
||||
namespace Cosmos.Common.Extensions {
|
||||
// This class duplicates BitConvertor. BitConvertor uses ulong though and currently does not
|
||||
|
|
@ -38,15 +39,21 @@ namespace Cosmos.Common.Extensions {
|
|||
static public string GetUtf8String(this byte[] n, UInt32 aStart, UInt32 aCharCount)
|
||||
{
|
||||
// TODO: This method handles ASCII only currently, no unicode.
|
||||
Debugger.DoSend("GetUtf8String");
|
||||
var xChars = new char[aCharCount];
|
||||
Debugger.DoSend("Array created");
|
||||
Debugger.DoSend("Charcount: ");
|
||||
Debugger.DoSendNumber(aCharCount);
|
||||
for (int i = 0; i < aCharCount; i++)
|
||||
{
|
||||
xChars[i] = (char)n[(aStart) + i];
|
||||
if (xChars[i] == 0)
|
||||
{
|
||||
Debugger.DoSend("Returning string");
|
||||
return new string(xChars, 0, i);
|
||||
}
|
||||
}
|
||||
Debugger.DoSend("Returning full string");
|
||||
return new string(xChars);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,3 +41,4 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("Cosmos.IL2CPU, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e3ef5198fa2f8926f006b5d2053eb3b3c875e74695675a6b97bd27ba6b0c5cbee26710c04277f7975927ace4a037692eddb71340a4c3f11e06c645c6a4cebad303301228943b39378bf3222f9432ff9c72c31d1a5e936db6cf9f18c23bd52a43c091fc803ce2139cd390a9678553d1e6061656c3d0196ddbd2233143fc433195")]
|
||||
[assembly: InternalsVisibleTo("Cosmos.Compiler.Tests.SimpleWriteLine.Kernel, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e3ef5198fa2f8926f006b5d2053eb3b3c875e74695675a6b97bd27ba6b0c5cbee26710c04277f7975927ace4a037692eddb71340a4c3f11e06c645c6a4cebad303301228943b39378bf3222f9432ff9c72c31d1a5e936db6cf9f18c23bd52a43c091fc803ce2139cd390a9678553d1e6061656c3d0196ddbd2233143fc433195")]
|
||||
[assembly: InternalsVisibleTo("Cosmos.TestRunner.TestController, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e3ef5198fa2f8926f006b5d2053eb3b3c875e74695675a6b97bd27ba6b0c5cbee26710c04277f7975927ace4a037692eddb71340a4c3f11e06c645c6a4cebad303301228943b39378bf3222f9432ff9c72c31d1a5e936db6cf9f18c23bd52a43c091fc803ce2139cd390a9678553d1e6061656c3d0196ddbd2233143fc433195")]
|
||||
[assembly: InternalsVisibleTo("Cosmos.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e3ef5198fa2f8926f006b5d2053eb3b3c875e74695675a6b97bd27ba6b0c5cbee26710c04277f7975927ace4a037692eddb71340a4c3f11e06c645c6a4cebad303301228943b39378bf3222f9432ff9c72c31d1a5e936db6cf9f18c23bd52a43c091fc803ce2139cd390a9678553d1e6061656c3d0196ddbd2233143fc433195")]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Debug.Kernel;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.IL2CPU.IL.CustomImplementations.System {
|
||||
|
|
@ -26,6 +27,7 @@ namespace Cosmos.IL2CPU.IL.CustomImplementations.System {
|
|||
//{
|
||||
// return "--object--";
|
||||
//}
|
||||
Debugger.DoSend("<Object.ToString not yet implemented!>");
|
||||
return "<Object.ToString not yet implemented!>";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Cosmos.Common.Extensions;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
using Cosmos.System.FileSystem;
|
||||
using Cosmos.System.FileSystem.VFS;
|
||||
|
||||
namespace SentinelKernel.System.Plugs.System.IO
|
||||
|
|
@ -19,6 +20,7 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
|
||||
public static string ReadAllText(string aFile)
|
||||
{
|
||||
FatHelpers.Debug("In FileImpl.ReadAllText");
|
||||
using (var xFS = new FileStream(aFile, FileMode.Open))
|
||||
{
|
||||
var xBuff = new byte[(int)xFS.Length];
|
||||
|
|
@ -27,8 +29,10 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
{
|
||||
throw new Exception("Couldn't read complete file!");
|
||||
}
|
||||
|
||||
return xBuff.GetUtf8String(0, (uint)xBuff.Length);
|
||||
FatHelpers.Debug("Bytes read");
|
||||
var xResultStr = xBuff.GetUtf8String(0, (uint)xBuff.Length);
|
||||
FatHelpers.Debug("ResultString retrieved");
|
||||
return xResultStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.IL2CPU.Plugs;
|
||||
using Cosmos.System.FileSystem;
|
||||
using Cosmos.System.FileSystem.VFS;
|
||||
|
||||
namespace SentinelKernel.System.Plugs.System.IO
|
||||
|
|
@ -244,11 +245,17 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
{
|
||||
return null;
|
||||
}
|
||||
FatHelpers.Debug("In PathImpl.GetPathRoot");
|
||||
aPath = NormalizePath(aPath, false);
|
||||
var xResult = aPath.Substring(0, GetRootLength(aPath));
|
||||
FatHelpers.Debug("Path normalized");
|
||||
var xRootLength = GetRootLength(aPath);
|
||||
FatHelpers.Debug("RootLength retrieved");
|
||||
FatHelpers.Debug("Value: " + xRootLength);
|
||||
var xResult = aPath.Substring(0, xRootLength);
|
||||
if (xResult[xResult.Length - 1] != Path.DirectorySeparatorChar)
|
||||
{
|
||||
xResult = xResult + Path.DirectorySeparatorChar;
|
||||
FatHelpers.Debug("Adding directory separator");
|
||||
xResult = String.Concat(xResult, Path.DirectorySeparatorChar);
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
|
|
@ -260,7 +267,10 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
|
||||
public static int GetRootLength(string aPath)
|
||||
{
|
||||
FatHelpers.Debug("In PathImpl.GetRootLength");
|
||||
CheckInvalidPathChars(aPath, false);
|
||||
FatHelpers.Debug("Checked for invalid path characters");
|
||||
FatHelpers.Debug("String length = " + aPath.Length);
|
||||
int i = 0;
|
||||
int length = aPath.Length;
|
||||
if (length >= 1 && IsDirectorySeparator(aPath[0]))
|
||||
|
|
@ -284,6 +294,7 @@ namespace SentinelKernel.System.Plugs.System.IO
|
|||
{
|
||||
if (length >= 2 && aPath[1] == VFSManager.GetVolumeSeparatorChar())
|
||||
{
|
||||
FatHelpers.Debug("Taking the '2' path");
|
||||
i = 2;
|
||||
if (length >= 3 && IsDirectorySeparator(aPath[2]))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -254,19 +254,19 @@ namespace Cosmos.System.FileSystem.FAT
|
|||
string xName = "";
|
||||
for (UInt32 i = 0; i < xData.Length; i = i + 32)
|
||||
{
|
||||
FatHelpers.Debug("-------------------------------------------------");
|
||||
FatHelpers.DevDebug("-------------------------------------------------");
|
||||
byte xAttrib = xData[i + 11];
|
||||
byte xStatus = xData[i];
|
||||
|
||||
FatHelpers.Debug("Attrib = " + xAttrib.ToString() + ", Status = " + xStatus);
|
||||
FatHelpers.DevDebug("Attrib = " + xAttrib.ToString() + ", Status = " + xStatus);
|
||||
if (xAttrib == DirectoryEntryAttributeConsts.LongName)
|
||||
{
|
||||
byte xType = xData[i + 12];
|
||||
byte xOrd = xData[i];
|
||||
FatHelpers.Debug("Reading LFN with Seqnr " + xOrd.ToString() + ", Type = " + xType);
|
||||
FatHelpers.DevDebug("Reading LFN with Seqnr " + xOrd.ToString() + ", Type = " + xType);
|
||||
if (xOrd == 0xE5)
|
||||
{
|
||||
FatHelpers.Debug("Skipping deleted entry");
|
||||
FatHelpers.DevDebug("Skipping deleted entry");
|
||||
continue;
|
||||
}
|
||||
if (xType == 0)
|
||||
|
|
@ -357,7 +357,7 @@ namespace Cosmos.System.FileSystem.FAT
|
|||
if (xAttrib == DirectoryEntryAttributeConsts.LongName)
|
||||
{
|
||||
// skip adding, as it's a LongFileName entry, meaning the next normal entry is the item with the name.
|
||||
FatHelpers.Debug("Entry was an Long FileName entry. Current LongName = '" + xLongName + "'");
|
||||
FatHelpers.DevDebug("Entry was an Long FileName entry. Current LongName = '" + xLongName + "'");
|
||||
}
|
||||
else if (xTest == 0)
|
||||
{
|
||||
|
|
@ -367,23 +367,23 @@ namespace Cosmos.System.FileSystem.FAT
|
|||
continue;
|
||||
}
|
||||
xResult.Add(new FatFile(this, xName, xSize, xFirstCluster));
|
||||
FatHelpers.Debug("Returning file '" + xName + "'");
|
||||
FatHelpers.DevDebug("Returning file '" + xName + "'");
|
||||
}
|
||||
else if (xTest == DirectoryEntryAttributeConsts.Directory)
|
||||
{
|
||||
UInt32 xSize = xData.ToUInt32(i + 28);
|
||||
var xFatDirectory = new FatDirectory(this, xName, xFirstCluster);
|
||||
FatHelpers.Debug("Returning directory '" + xFatDirectory.Name + "', FirstCluster = " + xFirstCluster);
|
||||
FatHelpers.DevDebug("Returning directory '" + xFatDirectory.Name + "', FirstCluster = " + xFirstCluster);
|
||||
xResult.Add(xFatDirectory);
|
||||
}
|
||||
else if (xTest == DirectoryEntryAttributeConsts.VolumeID)
|
||||
{
|
||||
FatHelpers.Debug("Directory entry is VolumeID");
|
||||
FatHelpers.DevDebug("Directory entry is VolumeID");
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
FatHelpers.Debug("Not sure what to do!");
|
||||
FatHelpers.DevDebug("Not sure what to do!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,5 +12,10 @@ namespace Cosmos.System.FileSystem
|
|||
{
|
||||
mDebugger.Send("FAT Debug: " + message);
|
||||
}
|
||||
|
||||
public static void DevDebug(string message)
|
||||
{
|
||||
mDebugger.Send("FAT DevDebug: " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ namespace Cosmos.System.FileSystem.VFS
|
|||
{
|
||||
throw new ArgumentNullException("aPath");
|
||||
}
|
||||
|
||||
FatHelpers.Debug("In VFSManager.TryGetFile");
|
||||
string xFileName = Path.GetFileName(aPath);
|
||||
string xDirectory = Path.GetDirectoryName(aPath);
|
||||
var xLastChar = xDirectory[xDirectory.Length - 1];
|
||||
|
|
@ -151,7 +151,7 @@ namespace Cosmos.System.FileSystem.VFS
|
|||
{
|
||||
xDirectory = xDirectory + Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
FatHelpers.Debug("Now Try to get directory listing");
|
||||
var xList = GetDirectoryListing(xDirectory);
|
||||
for (int i = 0; i < xList.Count; i++)
|
||||
{
|
||||
|
|
@ -280,6 +280,7 @@ namespace Cosmos.System.FileSystem.VFS
|
|||
{
|
||||
try
|
||||
{
|
||||
FatHelpers.Debug("In VFSManager.FileExists");
|
||||
return (VFSManager.TryGetFile(aPath) != null);
|
||||
}
|
||||
catch (Exception E)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,9 @@ namespace Cosmos.System
|
|||
|
||||
protected Cosmos.System.FileSystem.FileSystem GetFileSystemFromPath(string aPath)
|
||||
{
|
||||
FatHelpers.Debug("In SentinelVFS.GetFileSystemFromPath");
|
||||
string xPath = Path.GetPathRoot(aPath);
|
||||
FatHelpers.Debug("PathRoot retrieved");
|
||||
for (int i = 0; i < mFileSystems.Count; i++)
|
||||
{
|
||||
string xTest = mFileSystems[i].Key;
|
||||
|
|
@ -181,6 +183,8 @@ namespace Cosmos.System
|
|||
{
|
||||
throw new ArgumentNullException("aFS");
|
||||
}
|
||||
FatHelpers.Debug("In SentinelVFS.DoGetDirectory");
|
||||
FatHelpers.Debug("Path = " + aPath);
|
||||
string[] xPathParts = VFSManager.SplitPath(aPath);
|
||||
|
||||
if (xPathParts.Length == 1)
|
||||
|
|
@ -224,8 +228,11 @@ namespace Cosmos.System
|
|||
|
||||
public override List<Base> GetDirectoryListing(string aPath)
|
||||
{
|
||||
FatHelpers.Debug("In SentinelVFS.GetDirectoryListing");
|
||||
var xFS = GetFileSystemFromPath(aPath);
|
||||
FatHelpers.Debug("Filesystem retrieved");
|
||||
var xDirectory = DoGetDirectory(aPath, xFS);
|
||||
FatHelpers.Debug("Base directory retrieved.");
|
||||
return xFS.GetDirectoryListing(xDirectory);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue