mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 18:51:41 +00:00
Removed from DirectoryImpl.cs all the method that did not need plug anymore: CosmosFileSystem methods are called directly from Net Core code, the only remaing plugs are the ones that need IEnumerable to work.
This commit is contained in:
parent
d1a0beeea6
commit
f83aef39b0
4 changed files with 26 additions and 99 deletions
|
|
@ -38,7 +38,7 @@ namespace Cosmos.Kernel.Tests.Fat
|
|||
PathTest.Execute(mDebugger);
|
||||
DirectoryTest.Execute(mDebugger);
|
||||
FileTest.Execute(mDebugger);
|
||||
FileStreamTest.Execute(mDebugger);
|
||||
FileStreamTest.Execute(mDebugger);
|
||||
DirectoryInfoTest.Execute(mDebugger);
|
||||
|
||||
//StreamWriterTest.Execute(mDebugger);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,14 @@ namespace Cosmos.Kernel.Tests.Fat.System.IO
|
|||
|
||||
mDebugger.Send("");
|
||||
|
||||
mDebugger.Send("START TEST: Set Current Directory:");
|
||||
var ExpectedCurrentDirectory = @"0:\TestDir1";
|
||||
Directory.SetCurrentDirectory(ExpectedCurrentDirectory);
|
||||
var CurrentDirectory = Directory.GetCurrentDirectory();
|
||||
Assert.IsTrue(ExpectedCurrentDirectory == CurrentDirectory, "Current Directory is wrong!");
|
||||
mDebugger.Send("END TEST");
|
||||
|
||||
mDebugger.Send("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//#define COSMOSDEBUG
|
||||
#define COSMOSDEBUG
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -21,6 +21,12 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
[Plug(TargetName = "System.IO.FileSystem, System.IO.FileSystem", Inheritable = true)]
|
||||
public static class CosmosFileSystem
|
||||
{
|
||||
/*
|
||||
* This "trick" will work until we have not multi threading / multi process then you must do in the correct
|
||||
* way (an "attribute" of the running thread itself?)
|
||||
*/
|
||||
private static string mCurrentDirectory = string.Empty;
|
||||
|
||||
public static void CreateDirectory(object aThis, string fullPath)
|
||||
{
|
||||
// If 'fullPath' exists already we return already without dealing with VFSManager
|
||||
|
|
@ -69,12 +75,17 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
throw new NotImplementedException("MoveDirectory not implemented");
|
||||
}
|
||||
|
||||
#if false
|
||||
public static string GetCurrentDirectory(object aThis)
|
||||
{
|
||||
return "";
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.GetCurrentDirectory : mCurrentDirectory = {mCurrentDirectory}");
|
||||
return mCurrentDirectory;
|
||||
}
|
||||
|
||||
public static void SetCurrentDirectory(object aThis, string fullPath)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.SetCurrentDirectory : aPath = {fullPath}");
|
||||
mCurrentDirectory = fullPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static object /* FileStreamBase */ Open(object aThis, string fullPath, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, FileStream parent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Cosmos.Debug.Kernel;
|
||||
using Cosmos.IL2CPU.API;
|
||||
using Cosmos.IL2CPU.API.Attribs;
|
||||
using Cosmos.System;
|
||||
using Cosmos.System.FileSystem;
|
||||
using Cosmos.System.FileSystem.Listing;
|
||||
using Cosmos.System.FileSystem.VFS;
|
||||
|
||||
|
|
@ -15,97 +12,7 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
[Plug(Target = typeof(Directory))]
|
||||
public static class DirectoryImpl
|
||||
{
|
||||
private static string mCurrentDirectory = string.Empty;
|
||||
|
||||
public static string GetCurrentDirectory()
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.GetCurrentDirectory : mCurrentDirectory = {mCurrentDirectory}");
|
||||
return mCurrentDirectory;
|
||||
}
|
||||
|
||||
public static void SetCurrentDirectory(string aPath)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.SetCurrentDirectory : aPath = {aPath}");
|
||||
mCurrentDirectory = aPath;
|
||||
}
|
||||
|
||||
public static bool Exists(string aPath)
|
||||
{
|
||||
if (aPath == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.Exists : aPath = {aPath}");
|
||||
return VFSManager.DirectoryExists(aPath);
|
||||
}
|
||||
|
||||
public static DirectoryInfo CreateDirectory(string aPath)
|
||||
{
|
||||
if (aPath == null)
|
||||
{
|
||||
throw new ArgumentNullException("aPath");
|
||||
}
|
||||
|
||||
if (aPath.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Path must not be empty.", "aPath");
|
||||
}
|
||||
|
||||
Global.mFileSystemDebugger.SendInternal($"Directory.CreateDirectory : aPath = {aPath}");
|
||||
|
||||
var xEntry = VFSManager.CreateDirectory(aPath);
|
||||
|
||||
if (xEntry == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DirectoryInfo(aPath);
|
||||
}
|
||||
|
||||
public static void Delete(string aPath)
|
||||
{
|
||||
Delete(aPath, false);
|
||||
}
|
||||
|
||||
public static void Delete(string aPath, bool recursive)
|
||||
{
|
||||
String xFullPath = Path.GetFullPath(aPath);
|
||||
|
||||
VFSManager.DeleteDirectory(xFullPath, recursive);
|
||||
}
|
||||
|
||||
public static DirectoryInfo GetParent(string aPath)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetParent:");
|
||||
|
||||
if (aPath == null)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetParent : aPath is null");
|
||||
throw new ArgumentNullException("aPath");
|
||||
}
|
||||
|
||||
if (aPath.Length == 0)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetParent : aPath is empty");
|
||||
throw new ArgumentException("Path must not be empty.", "aPath");
|
||||
}
|
||||
|
||||
Global.mFileSystemDebugger.SendInternal("aPath =");
|
||||
Global.mFileSystemDebugger.SendInternal(aPath);
|
||||
|
||||
string xFullPath = Path.GetFullPath(aPath);
|
||||
string xParentDirectory = Path.GetDirectoryName(xFullPath);
|
||||
if (xParentDirectory == null)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetParent : xParentDirectory is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DirectoryInfo(xParentDirectory);
|
||||
}
|
||||
|
||||
/* The real implementation uses IEnumerable and do a conversion ToArray that crashes IL2CPU */
|
||||
public static string[] GetDirectories(string aPath)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetDirectories");
|
||||
|
|
@ -127,6 +34,7 @@ namespace Cosmos.System_Plugs.System.IO
|
|||
return xDirectories.ToArray();
|
||||
}
|
||||
|
||||
/* The real implementation uses IEnumerable and do a conversion ToArray that crashes IL2CPU */
|
||||
public static string[] GetFiles(string aPath)
|
||||
{
|
||||
Global.mFileSystemDebugger.SendInternal("Directory.GetFiles");
|
||||
|
|
|
|||
Loading…
Reference in a new issue