mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Fixed path plugs
This commit is contained in:
parent
a52ea7a514
commit
043cbb2f19
6 changed files with 214 additions and 69 deletions
|
|
@ -134,7 +134,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Cosmos.snk" />
|
<None Include="Cosmos.snk" />
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,121 @@
|
||||||
using Cosmos.IL2CPU.Plugs;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using Cosmos.IL2CPU.Plugs;
|
||||||
|
|
||||||
namespace Cosmos.Core.Plugs.System.IO
|
namespace Cosmos.Core.Plugs.System.IO
|
||||||
{
|
{
|
||||||
[Plug(TargetName = "System.IO.PathHelper")]
|
[Plug(TargetName = "System.IO.PathHelper")]
|
||||||
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||||
public static class PathHelperImpl
|
public static class PathHelperImpl
|
||||||
{
|
{
|
||||||
|
public static unsafe void Ctor(ref object aThis, char* aCharArrayPtr, int aLength,
|
||||||
|
[FieldAccess(Name = "System.Boolean System.IO.PathHelper.doNotTryExpandShortFileName")] ref bool mDoNotTryExpandShortFileName,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_capacity")] ref int mCapacity,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_maxPath")] ref int mMaxPath,
|
||||||
|
[FieldAccess(Name = "System.Boolean System.IO.PathHelper.useStackAlloc")] ref bool mUseStackAlloc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
mLength = 0;
|
||||||
|
mCapacity = aLength;
|
||||||
|
mArrayPtr = aCharArrayPtr;
|
||||||
|
mUseStackAlloc = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe void Ctor(ref object aThis, int aCapacity, int aMaxPath,
|
||||||
|
[FieldAccess(Name = "System.Boolean System.IO.PathHelper.doNotTryExpandShortFileName")] ref bool mDoNotTryExpandShortFileName,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_capacity")] ref int mCapacity,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_maxPath")] ref int mMaxPath,
|
||||||
|
[FieldAccess(Name = "System.Boolean System.IO.PathHelper.useStackAlloc")] ref bool mUseStackAlloc)
|
||||||
|
{
|
||||||
|
mLength = 0;
|
||||||
|
mCapacity = aCapacity;
|
||||||
|
mUseStackAlloc = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int get_Capacity(ref object aThis,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_capacity")] ref int mCapacity)
|
||||||
|
{
|
||||||
|
return mCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe char get_Item(ref object aThis, int aIndex,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
|
{
|
||||||
|
return mArrayPtr[aIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe void set_Item(ref object aThis, int aIndex, char aValue,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
|
{
|
||||||
|
mArrayPtr[aIndex] = aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int get_Length(ref object aThis,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength)
|
||||||
|
{
|
||||||
|
return mLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set_Length(ref object aThis, int aValue,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength)
|
||||||
|
{
|
||||||
|
mLength = aValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe void Append(ref object aThis, char aValue,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_capacity")] ref int mCapacity,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
|
{
|
||||||
|
if (mLength + 1 > mCapacity)
|
||||||
|
{
|
||||||
|
throw new PathTooLongException();
|
||||||
|
}
|
||||||
|
|
||||||
|
mArrayPtr[mLength] = aValue;
|
||||||
|
mLength++;
|
||||||
|
}
|
||||||
|
|
||||||
public static unsafe int GetFullPathName(ref object aThis,
|
public static unsafe int GetFullPathName(ref object aThis,
|
||||||
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* aArrayPtr)
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
{
|
{
|
||||||
int xLength = 0;
|
int xLength = 0;
|
||||||
while (*aArrayPtr != '\0')
|
while (*mArrayPtr != '\0')
|
||||||
{
|
{
|
||||||
xLength++;
|
xLength++;
|
||||||
aArrayPtr++;
|
mArrayPtr++;
|
||||||
}
|
}
|
||||||
|
mLength = xLength;
|
||||||
return xLength;
|
return xLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryExpandShortFileName(ref object aThis)
|
public static unsafe string ToString(ref object aThis,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
{
|
{
|
||||||
|
return new string(mArrayPtr, 0, mLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe bool TryExpandShortFileName(ref object aThis,
|
||||||
|
[FieldAccess(Name = "System.Int32 System.IO.PathHelper.m_length")] ref int mLength,
|
||||||
|
[FieldAccess(Name = "System.Char* System.IO.PathHelper.m_arrayPtr")] ref char* mArrayPtr)
|
||||||
|
{
|
||||||
|
int xLength = 0;
|
||||||
|
while (*mArrayPtr != '\0')
|
||||||
|
{
|
||||||
|
xLength++;
|
||||||
|
mArrayPtr++;
|
||||||
|
}
|
||||||
|
mLength = xLength;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -535,14 +535,14 @@ namespace Cosmos.IL2CPU.ILOpCodes {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((StackPopTypes[0] == typeof (IntPtr) && StackPopTypes[1] == typeof (UInt32*))
|
if ((StackPopTypes[0] == typeof (IntPtr) && StackPopTypes[1] == typeof (uint*))
|
||||||
|| (StackPopTypes[0] == typeof (uint*) && StackPopTypes[1] == typeof (IntPtr)))
|
|| (StackPopTypes[0] == typeof (uint*) && StackPopTypes[1] == typeof (IntPtr)))
|
||||||
{
|
{
|
||||||
StackPushTypes[0] = typeof (uint*);
|
StackPushTypes[0] = typeof (uint*);
|
||||||
aSituationChanged = true;
|
aSituationChanged = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((StackPopTypes[0] == typeof(UIntPtr) && StackPopTypes[1] == typeof(UInt32*))
|
if ((StackPopTypes[0] == typeof(UIntPtr) && StackPopTypes[1] == typeof(uint*))
|
||||||
|| (StackPopTypes[0] == typeof(uint*) && StackPopTypes[1] == typeof(UIntPtr)))
|
|| (StackPopTypes[0] == typeof(uint*) && StackPopTypes[1] == typeof(UIntPtr)))
|
||||||
{
|
{
|
||||||
StackPushTypes[0] = typeof(uint*);
|
StackPushTypes[0] = typeof(uint*);
|
||||||
|
|
@ -663,7 +663,7 @@ namespace Cosmos.IL2CPU.ILOpCodes {
|
||||||
}
|
}
|
||||||
if (StackPopTypes[0] == typeof(IntPtr) && StackPopTypes[1] == typeof(IntPtr))
|
if (StackPopTypes[0] == typeof(IntPtr) && StackPopTypes[1] == typeof(IntPtr))
|
||||||
{
|
{
|
||||||
StackPushTypes[0] = typeof(uint);
|
StackPushTypes[0] = typeof(IntPtr);
|
||||||
aSituationChanged = true;
|
aSituationChanged = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ namespace Cosmos.IL2CPU.ILOpCodes
|
||||||
}
|
}
|
||||||
xArgIndexCorrection = -1;
|
xArgIndexCorrection = -1;
|
||||||
}
|
}
|
||||||
|
string x = aMethod.Name;
|
||||||
var xParams = aMethod.GetParameters();
|
var xParams = aMethod.GetParameters();
|
||||||
StackPushTypes[0] = xParams[Value + xArgIndexCorrection].ParameterType;
|
StackPushTypes[0] = xParams[Value + xArgIndexCorrection].ParameterType;
|
||||||
if (StackPushTypes[0].IsEnum)
|
if (StackPushTypes[0].IsEnum)
|
||||||
|
|
@ -102,8 +103,6 @@ namespace Cosmos.IL2CPU.ILOpCodes
|
||||||
StackPushTypes[0] = StackPushTypes[0].GetEnumUnderlyingType();
|
StackPushTypes[0] = StackPushTypes[0].GetEnumUnderlyingType();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -423,20 +423,20 @@ namespace Cosmos.System.Plugs.System.IO
|
||||||
// return false;
|
// return false;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//public static bool IsDirectorySeparator(char aC)
|
public static bool IsDirectorySeparator(char aC)
|
||||||
//{
|
{
|
||||||
// if (aC.ToString() == Path.DirectorySeparatorChar.ToString())
|
if (aC.ToString() == Path.DirectorySeparatorChar.ToString())
|
||||||
// {
|
{
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (aC.ToString() == Path.AltDirectorySeparatorChar.ToString())
|
if (aC.ToString() == Path.AltDirectorySeparatorChar.ToString())
|
||||||
// {
|
{
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return false;
|
return false;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public static bool IsPathRooted(string aPath)
|
//public static bool IsPathRooted(string aPath)
|
||||||
//{
|
//{
|
||||||
|
|
@ -455,54 +455,54 @@ namespace Cosmos.System.Plugs.System.IO
|
||||||
// return false;
|
// return false;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//private static bool IsRelative(string aPath)
|
private static bool IsRelative(string aPath)
|
||||||
//{
|
{
|
||||||
// if (aPath == null)
|
if (aPath == null)
|
||||||
// {
|
{
|
||||||
// throw new ArgumentNullException("aPath");
|
throw new ArgumentNullException("aPath");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (aPath.Length < 3)
|
if (aPath.Length < 3)
|
||||||
// {
|
{
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (aPath[1] != Path.VolumeSeparatorChar)
|
if (aPath[1] != Path.VolumeSeparatorChar)
|
||||||
// {
|
{
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (aPath[2] != Path.DirectorySeparatorChar)
|
if (aPath[2] != Path.DirectorySeparatorChar)
|
||||||
// {
|
{
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return false;
|
return false;
|
||||||
//}
|
}
|
||||||
|
|
||||||
//public static string NormalizePath(string aPath, bool aFullCheck)
|
public static string NormalizePath(string aPath, bool aFullCheck)
|
||||||
//{
|
{
|
||||||
// if (aPath == null)
|
if (aPath == null)
|
||||||
// {
|
{
|
||||||
// Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath is null");
|
Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath is null");
|
||||||
// throw new ArgumentNullException("aPath");
|
throw new ArgumentNullException("aPath");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// string result = aPath;
|
string result = aPath;
|
||||||
// if (IsRelative(result))
|
if (IsRelative(result))
|
||||||
// {
|
{
|
||||||
// result = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + result;
|
result = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + result;
|
||||||
// Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath is relative, aPath = {aPath}, result = {result}");
|
Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath is relative, aPath = {aPath}, result = {result}");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (IsDirectorySeparator(result[result.Length - 1]))
|
if (IsDirectorySeparator(result[result.Length - 1]))
|
||||||
// {
|
{
|
||||||
// Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : Found directory seprator");
|
Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : Found directory seprator");
|
||||||
// result = result.Remove(result.Length - 1);
|
result = result.Remove(result.Length - 1);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath = {aPath}, returning {result}");
|
Global.mFileSystemDebugger.SendInternal($"Path.NormalizePath : aPath = {aPath}, returning {result}");
|
||||||
// return result;
|
return result;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,13 +294,44 @@ namespace Cosmos.System.FileSystem.VFS
|
||||||
|
|
||||||
public static char[] GetInvalidFileNameChars()
|
public static char[] GetInvalidFileNameChars()
|
||||||
{
|
{
|
||||||
char[] xReturn = { '"', '<', '>', '|', '\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r', ':', '*', '?', '\\', '/' };
|
char[] xReturn = new char[17];
|
||||||
|
xReturn[0] = '"';
|
||||||
|
xReturn[1] = '<';
|
||||||
|
xReturn[2] = '>';
|
||||||
|
xReturn[3] = '|';
|
||||||
|
xReturn[4] = '\0';
|
||||||
|
xReturn[5] = '\a';
|
||||||
|
xReturn[6] = '\b';
|
||||||
|
xReturn[7] = '\t';
|
||||||
|
xReturn[8] = '\n';
|
||||||
|
xReturn[9] = '\v';
|
||||||
|
xReturn[10] = '\f';
|
||||||
|
xReturn[11] = '\r';
|
||||||
|
xReturn[12] = ':';
|
||||||
|
xReturn[13] = '*';
|
||||||
|
xReturn[14] = '?';
|
||||||
|
xReturn[15] = '\\';
|
||||||
|
xReturn[16] = '/';
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char[] GetInvalidPathCharsWithAdditionalChecks()
|
public static char[] GetInvalidPathCharsWithAdditionalChecks()
|
||||||
{
|
{
|
||||||
char[] xReturn = { '"', '<', '>', '|', '\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '*', '?' };
|
char[] xReturn = new char[14];
|
||||||
|
xReturn[0] = '"';
|
||||||
|
xReturn[1] = '<';
|
||||||
|
xReturn[2] = '>';
|
||||||
|
xReturn[3] = '|';
|
||||||
|
xReturn[4] = '\0';
|
||||||
|
xReturn[5] = '\a';
|
||||||
|
xReturn[6] = '\b';
|
||||||
|
xReturn[7] = '\t';
|
||||||
|
xReturn[8] = '\n';
|
||||||
|
xReturn[9] = '\v';
|
||||||
|
xReturn[10] = '\f';
|
||||||
|
xReturn[11] = '\r';
|
||||||
|
xReturn[12] = '*';
|
||||||
|
xReturn[13] = '?';
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,13 +342,34 @@ namespace Cosmos.System.FileSystem.VFS
|
||||||
|
|
||||||
public static char[] GetRealInvalidPathChars()
|
public static char[] GetRealInvalidPathChars()
|
||||||
{
|
{
|
||||||
char[] xReturn = { '"', '<', '>', '|', '\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r' };
|
char[] xReturn = new char[12];
|
||||||
|
xReturn[0] = '"';
|
||||||
|
xReturn[1] = '<';
|
||||||
|
xReturn[2] = '>';
|
||||||
|
xReturn[3] = '|';
|
||||||
|
xReturn[4] = '\0';
|
||||||
|
xReturn[5] = '\a';
|
||||||
|
xReturn[6] = '\b';
|
||||||
|
xReturn[7] = '\t';
|
||||||
|
xReturn[8] = '\n';
|
||||||
|
xReturn[9] = '\v';
|
||||||
|
xReturn[10] = '\f';
|
||||||
|
xReturn[11] = '\r';
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char[] GetTrimEndChars()
|
public static char[] GetTrimEndChars()
|
||||||
{
|
{
|
||||||
return new[] { (char)0x9, (char)0xA, (char)0xB, (char)0xC, (char)0xD, (char)0x20, (char)0x85, (char)0xA0 };
|
char[] xReturn = new char[8];
|
||||||
|
xReturn[0] = (char)0x9;
|
||||||
|
xReturn[1] = (char)0xA;
|
||||||
|
xReturn[2] = (char)0xB;
|
||||||
|
xReturn[3] = (char)0xC;
|
||||||
|
xReturn[4] = (char)0xD;
|
||||||
|
xReturn[5] = (char)0x20;
|
||||||
|
xReturn[6] = (char)0x85;
|
||||||
|
xReturn[7] = (char)0xA0;
|
||||||
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char GetVolumeSeparatorChar()
|
public static char GetVolumeSeparatorChar()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue