From ceeb1381e1b0ec79a2b037df244e7fad98f80c64 Mon Sep 17 00:00:00 2001 From: Charles Betros Date: Thu, 12 Nov 2015 22:27:12 -0600 Subject: [PATCH] Added tracing for some system io plugs and hooked up GetVolume and GetVolumes. --- .../Kernel.cs | 3 - .../System/IO/DirectoryImpl.cs | 10 + .../Cosmos.System.Plugs/System/IO/PathImpl.cs | 82 +++- .../FileSystem/VFS/VFSManager.cs | 458 ++---------------- 4 files changed, 128 insertions(+), 425 deletions(-) diff --git a/Tests/Cosmos.Kernel.Tests.FileSystemPlugs/Kernel.cs b/Tests/Cosmos.Kernel.Tests.FileSystemPlugs/Kernel.cs index a13aee7d2..e4d7f8c2f 100644 --- a/Tests/Cosmos.Kernel.Tests.FileSystemPlugs/Kernel.cs +++ b/Tests/Cosmos.Kernel.Tests.FileSystemPlugs/Kernel.cs @@ -59,11 +59,8 @@ namespace Cosmos.Kernel.Tests.FileSystemPlugs RunEQTest(Path.GetDirectoryName(@"0:\test"), @"0:\", "Path.GetDirectoryName (directory no trailing directory separator) failed."); RunEQTest(Path.GetDirectoryName(@"0:\test\"), @"0:\", "Path.GetDirectoryName (directory with trailing directory separator) failed."); RunEQTest(Path.GetDirectoryName(@"0:\test\test2"), @"0:\test", "Path.GetDirectoryName (subdirectory no trailing directory separator) failed."); - - // Broken RunEQTest(Path.GetDirectoryName(@"0:\test\test2\"), @"0:\test", "Path.GetDirectoryName (subdirectory with trailing directory separator) failed."); RunEQTest(Path.GetDirectoryName(@"0:\test\ ."), @"0:\test", "Path.GetDirectoryName (directory with trailing directory separator and invalid path) failed."); - // // Path.GetExtension(string) RunEQTest(Path.GetExtension(@"file"), string.Empty, "Path.GetExtension (file no extension) failed."); diff --git a/source/Cosmos.System.Plugs/System/IO/DirectoryImpl.cs b/source/Cosmos.System.Plugs/System/IO/DirectoryImpl.cs index f3ff6f61a..824b12e7a 100644 --- a/source/Cosmos.System.Plugs/System/IO/DirectoryImpl.cs +++ b/source/Cosmos.System.Plugs/System/IO/DirectoryImpl.cs @@ -6,6 +6,8 @@ using Cosmos.System.FileSystem.VFS; namespace Cosmos.System.Plugs.System.IO { + using Cosmos.System.FileSystem; + [Plug(Target = typeof(Directory))] public static class DirectoryImpl { @@ -13,21 +15,29 @@ namespace Cosmos.System.Plugs.System.IO public static string GetCurrentDirectory() { + FatHelpers.Debug("-- Directory.GetCurrentDirectory --"); + return mCurrentDirectory; } public static void SetCurrentDirectory(string aPath) { + FatHelpers.Debug("-- Directory.SetCurrentDirectory --"); + mCurrentDirectory = aPath; } public static bool Exists(string aPath) { + FatHelpers.Debug("-- Directory.Exists --"); + return VFSManager.DirectoryExists(aPath); } public static DirectoryInfo GetParent(string aPath) { + FatHelpers.Debug("-- Directory.GetParent --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); diff --git a/source/Cosmos.System.Plugs/System/IO/PathImpl.cs b/source/Cosmos.System.Plugs/System/IO/PathImpl.cs index 65f9146d6..19c114e6c 100644 --- a/source/Cosmos.System.Plugs/System/IO/PathImpl.cs +++ b/source/Cosmos.System.Plugs/System/IO/PathImpl.cs @@ -32,6 +32,8 @@ namespace Cosmos.System.Plugs.System.IO public static string ChangeExtension(string aPath, string aExtension) { + FatHelpers.Debug("-- Path.ChangeExtension --"); + if (aPath != null) { CheckInvalidPathChars(aPath, false); @@ -65,6 +67,8 @@ namespace Cosmos.System.Plugs.System.IO public static void CheckInvalidPathChars(string aPath, bool aCheckAdditional) { + FatHelpers.Debug("-- Path.CheckInvalidPathChars --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -78,6 +82,8 @@ namespace Cosmos.System.Plugs.System.IO public static void CheckSearchPattern(string aSearchPattern) { + FatHelpers.Debug("-- Path.CheckSearchPattern --"); + int xNum; while ((xNum = aSearchPattern.IndexOf("..", StringComparison.Ordinal)) != -1) { @@ -86,7 +92,7 @@ namespace Cosmos.System.Plugs.System.IO throw new ArgumentException("The search pattern is invalid.", aSearchPattern); } - if (aSearchPattern[xNum + 2] == VFSManager.GetDirectorySeparatorChar() || aSearchPattern[xNum + 2] == VFSManager.GetAltDirectorySeparatorChar()) + if (aSearchPattern[xNum + 2] == Path.DirectorySeparatorChar || aSearchPattern[xNum + 2] == Path.AltDirectorySeparatorChar) { throw new ArgumentException("The search pattern is invalid.", aSearchPattern); } @@ -97,6 +103,8 @@ namespace Cosmos.System.Plugs.System.IO public static string Combine(string aPath1, string aPath2) { + FatHelpers.Debug("-- Path.Combine --"); + if (aPath1 == null || aPath2 == null) { throw new ArgumentNullException((aPath1 == null) ? "path1" : "path2"); @@ -109,6 +117,8 @@ namespace Cosmos.System.Plugs.System.IO public static string CombineNoChecks(string aPath1, string aPath2) { + FatHelpers.Debug("-- Path.CombineNoChecks --"); + if (aPath2.Length == 0) { return aPath1; @@ -119,13 +129,13 @@ namespace Cosmos.System.Plugs.System.IO return aPath2; } - if (Path.IsPathRooted(aPath2)) + if (IsPathRooted(aPath2)) { return aPath2; } char xC = aPath1[aPath1.Length - 1]; - if (xC != VFSManager.GetDirectorySeparatorChar() && xC != VFSManager.GetAltDirectorySeparatorChar() && xC != VFSManager.GetVolumeSeparatorChar()) + if (xC != Path.DirectorySeparatorChar && xC != Path.AltDirectorySeparatorChar && xC != Path.VolumeSeparatorChar) { return aPath1 + "\\" + aPath2; } @@ -135,6 +145,8 @@ namespace Cosmos.System.Plugs.System.IO public static string GetDirectoryName(string aPath) { + FatHelpers.Debug("-- Path.GetDirectoryName --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -152,7 +164,7 @@ namespace Cosmos.System.Plugs.System.IO return null; } - while (xNum > xRootLength && xPath[--xNum] != VFSManager.GetDirectorySeparatorChar() && xPath[xNum] != VFSManager.GetAltDirectorySeparatorChar()) + while (xNum > xRootLength && xPath[--xNum] != Path.DirectorySeparatorChar && xPath[xNum] != Path.AltDirectorySeparatorChar) { } @@ -164,6 +176,8 @@ namespace Cosmos.System.Plugs.System.IO public static string GetExtension(string aPath) { + FatHelpers.Debug("-- Path.GetExtension --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -185,7 +199,7 @@ namespace Cosmos.System.Plugs.System.IO return string.Empty; } - if (xC == VFSManager.GetDirectorySeparatorChar() || xC == VFSManager.GetAltDirectorySeparatorChar() || xC == VFSManager.GetVolumeSeparatorChar()) + if (xC == Path.DirectorySeparatorChar || xC == Path.AltDirectorySeparatorChar || xC == Path.VolumeSeparatorChar) { break; } @@ -195,6 +209,8 @@ namespace Cosmos.System.Plugs.System.IO public static string GetFileName(string aPath) { + FatHelpers.Debug("-- Path.GetFileName --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -206,7 +222,7 @@ namespace Cosmos.System.Plugs.System.IO while (--xNum >= 0) { char xC = aPath[xNum]; - if (xC == VFSManager.GetDirectorySeparatorChar() || xC == VFSManager.GetAltDirectorySeparatorChar() || xC == VFSManager.GetVolumeSeparatorChar()) + if (xC == Path.DirectorySeparatorChar || xC == Path.AltDirectorySeparatorChar || xC == Path.VolumeSeparatorChar) { return aPath.Substring(xNum + 1, xLength - xNum - 1); } @@ -217,7 +233,9 @@ namespace Cosmos.System.Plugs.System.IO public static string GetFileNameWithoutExtension(string aPath) { - aPath = Path.GetFileName(aPath); + FatHelpers.Debug("-- Path.GetFileNameWithoutExtension --"); + + aPath = GetFileName(aPath); if (aPath == null) { return null; @@ -232,11 +250,15 @@ namespace Cosmos.System.Plugs.System.IO public static string GetFullPath(string aPath) { + FatHelpers.Debug("-- Path.GetFullPath --"); + return GetFullPathInternal(aPath); } public static string GetFullPathInternal(string aPath) { + FatHelpers.Debug("-- Path.GetFullPathInternal --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -247,16 +269,22 @@ namespace Cosmos.System.Plugs.System.IO public static char[] GetInvalidFileNameChars() { + FatHelpers.Debug("-- Path.GetInvalidFileNameChars --"); + return VFSManager.GetInvalidFileNameChars(); } public static char[] GetInvalidPathChars() { + FatHelpers.Debug("-- Path.GetInvalidPathChars --"); + return VFSManager.GetRealInvalidPathChars(); } public static string GetPathRoot(string aPath) { + FatHelpers.Debug("-- Path.GetPathRoot --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -275,11 +303,15 @@ namespace Cosmos.System.Plugs.System.IO public static string GetRandomFileName() { + FatHelpers.Debug("-- Path.GetRandomFileName --"); + return "random.tmp"; } public static int GetRootLength(string aPath) { + FatHelpers.Debug("-- Path.GetRootLength --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -297,7 +329,7 @@ namespace Cosmos.System.Plugs.System.IO int num = 2; while (i < length) { - if ((aPath[i] == VFSManager.GetDirectorySeparatorChar() || aPath[i] == VFSManager.GetAltDirectorySeparatorChar()) && --num <= 0) + if ((aPath[i] == Path.DirectorySeparatorChar || aPath[i] == Path.AltDirectorySeparatorChar) && --num <= 0) { break; } @@ -305,7 +337,7 @@ namespace Cosmos.System.Plugs.System.IO } } } - else if (length >= 2 && aPath[1] == VFSManager.GetVolumeSeparatorChar()) + else if (length >= 2 && aPath[1] == Path.VolumeSeparatorChar) { i = 2; if (length >= 3 && IsDirectorySeparator(aPath[2])) @@ -319,16 +351,22 @@ namespace Cosmos.System.Plugs.System.IO public static string GetTempFileName() { + FatHelpers.Debug("-- Path.GetTempFileName --"); + return "tempfile.tmp"; } public static string GetTempPath() { + FatHelpers.Debug("-- Path.GetTempPath --"); + return @"\Temp"; } public static bool HasExtension(string aPath) { + FatHelpers.Debug("-- Path.HasExtension --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -344,7 +382,7 @@ namespace Cosmos.System.Plugs.System.IO return xNum != aPath.Length - 1; } - if (xC == VFSManager.GetDirectorySeparatorChar() || xC == VFSManager.GetAltDirectorySeparatorChar() || xC == VFSManager.GetVolumeSeparatorChar()) + if (xC == Path.DirectorySeparatorChar || xC == Path.AltDirectorySeparatorChar || xC == Path.VolumeSeparatorChar) { break; } @@ -355,13 +393,19 @@ namespace Cosmos.System.Plugs.System.IO public static bool HasIllegalCharacters(string aPath, bool aCheckAdditional) { + FatHelpers.Debug("-- Path.HasIllegalCharacters --"); + if (aPath == null) { + FatHelpers.Debug("-- Path.HasIllegalCharacters : Path is null --"); + throw new ArgumentNullException("aPath"); } if (aCheckAdditional) { + FatHelpers.Debug("-- Path.HasIllegalCharacters : Check additional --"); + return aPath.IndexOfAny(VFSManager.GetInvalidPathCharsWithAdditionalChecks()) >= 0; } @@ -370,11 +414,15 @@ namespace Cosmos.System.Plugs.System.IO public static bool IsDirectorySeparator(char aC) { - return aC == VFSManager.GetDirectorySeparatorChar() || aC == VFSManager.GetAltDirectorySeparatorChar(); + FatHelpers.Debug("-- Path.IsDirectorySeparator --"); + + return aC == Path.DirectorySeparatorChar || aC == Path.AltDirectorySeparatorChar; } public static bool IsPathRooted(string aPath) { + FatHelpers.Debug("-- Path.IsPathRooted --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -382,7 +430,7 @@ namespace Cosmos.System.Plugs.System.IO CheckInvalidPathChars(aPath, false); int xLength = aPath.Length; - if ((xLength >= 1 && (aPath[0] == VFSManager.GetDirectorySeparatorChar() || aPath[0] == VFSManager.GetAltDirectorySeparatorChar())) || (xLength >= 2 && aPath[1] == VFSManager.GetVolumeSeparatorChar())) + if ((xLength >= 1 && (aPath[0] == Path.DirectorySeparatorChar || aPath[0] == Path.AltDirectorySeparatorChar)) || (xLength >= 2 && aPath[1] == Path.VolumeSeparatorChar)) { return true; } @@ -392,16 +440,20 @@ namespace Cosmos.System.Plugs.System.IO public static bool IsRelative(string aPath) { + FatHelpers.Debug("-- Path.IsRelative --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); } - return (aPath.Length < 3 || aPath[1] != VFSManager.GetVolumeSeparatorChar() || aPath[2] != VFSManager.GetDirectorySeparatorChar()); + return (aPath.Length < 3 || aPath[1] != Path.VolumeSeparatorChar || aPath[2] != Path.DirectorySeparatorChar); } public static string NormalizePath(string aPath, bool aFullCheck) { + FatHelpers.Debug("-- Path.NormalizePath --"); + if (aPath == null) { throw new ArgumentNullException("aPath"); @@ -409,10 +461,10 @@ namespace Cosmos.System.Plugs.System.IO if (IsRelative(aPath)) { - return Directory.GetCurrentDirectory() + VFSManager.GetDirectorySeparatorChar() + aPath; + return Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + aPath; } - return aPath.TrimEnd(VFSManager.GetDirectorySeparatorChar(), VFSManager.GetAltDirectorySeparatorChar()); + return aPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } } } diff --git a/source/Cosmos.System/FileSystem/VFS/VFSManager.cs b/source/Cosmos.System/FileSystem/VFS/VFSManager.cs index b5882b162..eaf120161 100644 --- a/source/Cosmos.System/FileSystem/VFS/VFSManager.cs +++ b/source/Cosmos.System/FileSystem/VFS/VFSManager.cs @@ -11,7 +11,8 @@ namespace Cosmos.System.FileSystem.VFS public static void RegisterVFS(VFSBase aVFS) { - Global.Dbg.Send("VFSManager.RegisterVFS"); + FatHelpers.Debug("-- VFSManager.RegisterVFS --"); + if (mVFS != null) { throw new Exception("Virtual File System Manager already initialized!"); @@ -25,16 +26,22 @@ namespace Cosmos.System.FileSystem.VFS public static char GetAltDirectorySeparatorChar() { + FatHelpers.Debug("-- VFSManager.GetAltDirectorySeparatorChar --"); + return '/'; } public static char GetDirectorySeparatorChar() { + FatHelpers.Debug("-- VFSManager.GetDirectorySeparatorChar --"); + return '\\'; } public static char[] GetInvalidFileNameChars() { + FatHelpers.Debug("-- VFSManager.GetInvalidFileNameChars --"); + return new[] { '"', @@ -59,6 +66,8 @@ namespace Cosmos.System.FileSystem.VFS public static char[] GetInvalidPathCharsWithAdditionalChecks() { + FatHelpers.Debug("-- VFSManager.GetInvalidPathCharsWithAdditionalChecks --"); + return new[] { '"', @@ -80,11 +89,15 @@ namespace Cosmos.System.FileSystem.VFS public static char GetPathSeparator() { + FatHelpers.Debug("-- VFSManager.GetPathSeparator --"); + return ';'; } public static char[] GetRealInvalidPathChars() { + FatHelpers.Debug("-- VFSManager.GetRealInvalidPathChars --"); + return new[] { '"', @@ -104,11 +117,15 @@ namespace Cosmos.System.FileSystem.VFS public static char GetVolumeSeparatorChar() { + FatHelpers.Debug("-- VFSManager.GetVolumeSeparatorChar --"); + return ':'; } public static int GetMaxPath() { + FatHelpers.Debug("-- VFSManager.GetMaxPath --"); + return 260; } @@ -124,12 +141,16 @@ namespace Cosmos.System.FileSystem.VFS public static string[] SplitPath(string aPath) { + FatHelpers.Debug("-- VFSManager.SplitPath --"); + //TODO: This should call Path.GetDirectoryName() and then loop calling Directory.GetParent(), but those aren't implemented yet. return aPath.Split(GetDirectorySeparators(), StringSplitOptions.RemoveEmptyEntries); } private static char[] GetDirectorySeparators() { + FatHelpers.Debug("-- VFSManager.GetDirectorySeparators --"); + return new[] { GetDirectorySeparatorChar(), GetAltDirectorySeparatorChar() }; } @@ -137,6 +158,8 @@ namespace Cosmos.System.FileSystem.VFS public static DirectoryEntry GetFile(string aPath) { + FatHelpers.Debug("-- VFSManager.GetFile --"); + if (string.IsNullOrEmpty(aPath)) { throw new ArgumentNullException("aPath"); @@ -150,28 +173,10 @@ namespace Cosmos.System.FileSystem.VFS xDirectory = xDirectory + Path.DirectorySeparatorChar; } - FatHelpers.Debug("VFSManager::GetFile: aPath = " + aPath); - FatHelpers.Debug("VFSManager::GetFile: xFileName = " + xFileName); - FatHelpers.Debug("VFSManager::GetFile: xDirectory = " + xDirectory); - var xList = GetDirectoryListing(xDirectory); for (int i = 0; i < xList.Count; i++) { var xEntry = xList[i]; - if (xEntry != null) - { - if (xEntry.EntryType == DirectoryEntryTypeEnum.File) - { - FatHelpers.Debug("VFSManager::GetFile: xEntry.EntryType = File"); - } - else - { - FatHelpers.Debug("VFSManager::GetFile: xEntry.EntryType = Directory"); - } - FatHelpers.Debug("VFSManager::GetFile: xEntry.Name = " + xEntry.Name); - FatHelpers.Debug("VFSManager::GetFile: xEntry.Size = " + xEntry.Size); - } - if ((xEntry != null) && (xEntry.EntryType == DirectoryEntryTypeEnum.File) && (xEntry.Name.ToUpper() == xFileName.ToUpper())) { return xEntry; @@ -183,6 +188,8 @@ namespace Cosmos.System.FileSystem.VFS public static DirectoryInfo CreateDirectory(string aPath) { + FatHelpers.Debug("-- VFSManager.CreateDirectory --"); + if (string.IsNullOrEmpty(aPath)) { throw new ArgumentNullException("aPath"); @@ -206,6 +213,8 @@ namespace Cosmos.System.FileSystem.VFS public static DirectoryEntry GetDirectory(string aPath) { + FatHelpers.Debug("-- VFSManager.GetDirectory --"); + if (string.IsNullOrEmpty(aPath)) { throw new ArgumentNullException("aPath"); @@ -216,6 +225,8 @@ namespace Cosmos.System.FileSystem.VFS public static List GetDirectoryListing(string aPath) { + FatHelpers.Debug("-- VFSManager.GetDirectoryListing --"); + if (string.IsNullOrEmpty(aPath)) { throw new ArgumentNullException("aPath"); @@ -226,21 +237,27 @@ namespace Cosmos.System.FileSystem.VFS public static DirectoryEntry GetVolume(string aVolume) { + FatHelpers.Debug("-- VFSManager.GetVolume --"); + if (string.IsNullOrEmpty(aVolume)) { throw new ArgumentNullException("aVolume"); } - return null; + return mVFS.GetVolume(aVolume); } public static List GetVolumes() { - return null; + FatHelpers.Debug("-- VFSManager.GetVolumes --"); + + return mVFS.GetVolumes(); } public static List GetLogicalDrives() { + FatHelpers.Debug("-- VFSManager.GetLogicalDrives --"); + //TODO: Directory.GetLogicalDrives() will call this. return null; @@ -256,6 +273,8 @@ namespace Cosmos.System.FileSystem.VFS public static List InternalGetFileDirectoryNames(string path, string userPathOriginal, string searchPattern, bool includeFiles, bool includeDirs, SearchOption searchOption) { + FatHelpers.Debug("-- VFSManager.InternalGetFileDirectoryNames --"); + return null; /* @@ -291,6 +310,8 @@ namespace Cosmos.System.FileSystem.VFS public static bool FileExists(string aPath) { + FatHelpers.Debug("-- VFSManager.FileExists --"); + try { string xPath = Path.GetFullPath(aPath); @@ -306,6 +327,8 @@ namespace Cosmos.System.FileSystem.VFS public static bool FileExists(DirectoryEntry aEntry) { + FatHelpers.Debug("-- VFSManager.FileExists --"); + try { string xPath = GetFullPath(aEntry); @@ -321,6 +344,8 @@ namespace Cosmos.System.FileSystem.VFS public static bool DirectoryExists(string aPath) { + FatHelpers.Debug("-- VFSManager.DirectoryExists --"); + try { string xPath = Path.GetFullPath(aPath); @@ -336,6 +361,8 @@ namespace Cosmos.System.FileSystem.VFS public static bool DirectoryExists(DirectoryEntry aEntry) { + FatHelpers.Debug("-- VFSManager.DirectoryExists --"); + try { string xPath = GetFullPath(aEntry); @@ -351,6 +378,8 @@ namespace Cosmos.System.FileSystem.VFS public static string GetFullPath(DirectoryEntry aEntry) { + FatHelpers.Debug("-- VFSManager.GetFullPath --"); + DirectoryEntry xEntry = aEntry; string xPath = string.Empty; @@ -365,7 +394,7 @@ namespace Cosmos.System.FileSystem.VFS public static Stream GetFileStream(string aPathname) { - FatHelpers.Debug("VFSManager::GetFileStream: aPathName = " + aPathname); + FatHelpers.Debug("-- VFSManager.GetFileStream --"); var xFileInfo = GetFile(aPathname); if (xFileInfo == null) @@ -376,389 +405,4 @@ namespace Cosmos.System.FileSystem.VFS return xFileInfo.FileSystem.GetFileStream(xFileInfo); } } - - //public static class VFSManager - //{ - // private static VFSBase mVFS; - - // public static void RegisterVFS(VFSBase aVFS) - // { - // Cosmos.System.Global.Dbg.Send("VFSManager.RegisterVFS"); - // if (mVFS != null) - // { - // throw new Exception("Virtual File System Manager already initialized!"); - // } - - // aVFS.Initialize(); - // mVFS = aVFS; - // } - - // #region Helpers - - // public static char GetAltDirectorySeparatorChar() - // { - // return '/'; - // } - - // public static char GetDirectorySeparatorChar() - // { - // return '\\'; - // } - - // public static char[] GetInvalidFileNameChars() - // { - // return new[] - // { - // '"', - // '<', - // '>', - // '|', - // '\0', - // '\a', - // '\b', - // '\t', - // '\n', - // '\v', - // '\f', - // '\r', - // ':', - // '*', - // '?', - // '\\', - // '/' - // }; - // } - - // public static char[] GetInvalidPathCharsWithAdditionalChecks() - // { - // return new[] - // { - // '"', - // '<', - // '>', - // '|', - // '\0', - // '\a', - // '\b', - // '\t', - // '\n', - // '\v', - // '\f', - // '\r', - // '*', - // '?' - // }; - // } - - // public static char GetPathSeparator() - // { - // return ';'; - // } - - // public static char[] GetRealInvalidPathChars() - // { - // return new[] - // { - // '"', - // '<', - // '>', - // '|', - // '\0', - // '\a', - // '\b', - // '\t', - // '\n', - // '\v', - // '\f', - // '\r' - // }; - // } - - // public static char GetVolumeSeparatorChar() - // { - // return ':'; - // } - - // public static int GetMaxPath() - // { - // return 260; - // } - - // //public static bool IsAbsolutePath(this string aPath) - // //{ - // // return ((aPath[0] == VFSBase.DirectorySeparatorChar) || (aPath[0] == VFSBase.AltDirectorySeparatorChar)); - // //} - - // //public static bool IsRelativePath(this string aPath) - // //{ - // // return (aPath[0] != VFSBase.DirectorySeparatorChar || aPath[0] != VFSBase.AltDirectorySeparatorChar); - // //} - - // public static string[] SplitPath(string aPath) - // { - // //TODO: This should call Path.GetDirectoryName() and then loop calling Directory.GetParent(), but those aren't implemented yet. - // return aPath.Split(GetDirectorySeparators(), StringSplitOptions.RemoveEmptyEntries); - // } - - // private static char[] GetDirectorySeparators() - // { - // return new[] { GetDirectorySeparatorChar(), GetAltDirectorySeparatorChar() }; - // } - - // #endregion - - // public static Listing.File TryGetFile(string aPath) - // { - // if (aPath == null) - // { - // throw new Exception("Path can not be null."); - // } - // FatHelpers.Debug("In VFSManager.TryGetFile"); - // FatHelpers.Debug(aPath); - // string xFileName = Path.GetFileName(aPath); - // string xDirectory = Path.GetDirectoryName(aPath); - // var xLastChar = xDirectory[xDirectory.Length - 1]; - // if (xLastChar != Path.DirectorySeparatorChar) - // { - // xDirectory = xDirectory + Path.DirectorySeparatorChar; - // } - // FatHelpers.Debug("Now Try to get directory listing"); - // var xList = GetDirectoryListing(xDirectory); - // for (int i = 0; i < xList.Count; i++) - // { - // var xEntry = xList[i]; - // var xFile = xEntry as Listing.File; - // if (xFile != null && String.Equals(xEntry.Name, xFileName, StringComparison.OrdinalIgnoreCase)) - // { - // FatHelpers.Debug("--- Returning file"); - // FatHelpers.Debug("Name"); - // FatHelpers.Debug(xFile.Name); - // return xFile; - // } - // } - - // return null; - // } - - // public static Listing.Directory TryGetDirectory(string aPath) - // { - // if (string.IsNullOrEmpty(aPath)) - // { - // throw new Exception("Path can not be null."); - // } - // FatHelpers.Debug("In VFSManager.TryGetFile"); - // string xFileName = Path.GetFileName(aPath); - // string xDirectory = Path.GetDirectoryName(aPath); - // FatHelpers.Debug("Filename: "); - // FatHelpers.Debug(xFileName); - // FatHelpers.Debug("Directory:"); - // FatHelpers.Debug(xDirectory); - // var xLastChar = xDirectory[xDirectory.Length - 1]; - // if (xLastChar != Path.DirectorySeparatorChar) - // { - // xDirectory = xDirectory + Path.DirectorySeparatorChar; - // } - // FatHelpers.Debug("Now Try to get directory listing"); - // var xList = GetDirectoryListing(xDirectory); - // FatHelpers.DebugNumber((uint) xList.Count); - // for (int i = 0; i < xList.Count; i++) - // { - // var xEntry = xList[i]; - // var xFile = xEntry as Listing.Directory; - // if (xFile != null && String.Equals(xEntry.Name, xFileName, StringComparison.OrdinalIgnoreCase)) - // { - // return xFile; - // } - // else - // { - // FatHelpers.Debug("--Skipping item"); - // if (xFile == null) - // { - // FatHelpers.Debug(" File"); - // } - // else - // { - // FatHelpers.Debug(" Directory"); - // } - // FatHelpers.Debug(" Name"); - // FatHelpers.Debug(xEntry.Name); - - // } - // } - - // FatHelpers.Debug("Directory not found"); - // FatHelpers.Debug(xFileName); - // return null; - // } - - // public static List GetFiles(string aPath) - // { - // if (string.IsNullOrEmpty(aPath)) - // { - // throw new Exception("Path can not be null."); - // } - - // return null; - - // /* - // List xFiles = new List(); - // var xDirName = Path.GetDirectoryName(aPath); - // var xEntries = GetDirectoryListing(xDirName); - - // for (int i = 0; i < xEntries.Length; i++) - // { - // var entry = xEntries[i]; - // if (!entry.IsDirectory) - // xFiles.Add(entry); - // } - - // return xFiles.ToArray(); - // */ - // } - - // public static Listing.Directory GetDirectory(string aPath) - // { - // if (string.IsNullOrEmpty(aPath)) - // { - // throw new Exception("Path can not be null."); - // } - // FatHelpers.Debug("In VFSManager.GetDirectory"); - - // return mVFS.GetDirectory(aPath); - // } - - // public static List GetDirectoryListing(string aPath) - // { - // if (string.IsNullOrEmpty(aPath)) - // { - // throw new Exception("Path can not be null."); - // } - - // return mVFS.GetDirectoryListing(aPath); - // } - - // public static Listing.Directory GetVolume(string aVolume) - // { - // if (string.IsNullOrEmpty(aVolume)) - // { - // throw new Exception("Path can not be null."); - // } - - // return null; - // } - - // public static List GetVolumes() - // { - // return null; - // } - - - - // public static List GetLogicalDrives() - // { - // //TODO: Directory.GetLogicalDrives() will call this. - // return null; - - // /* - // List xDrives = new List(); - // foreach (FilesystemEntry entry in GetVolumes()) - // xDrives.Add(entry.Name + Path.VolumeSeparatorChar + Path.DirectorySeparatorChar); - - // return xDrives.ToArray(); - // */ - // } - - // public static List InternalGetFileDirectoryNames(string path, string userPathOriginal, string searchPattern, bool includeFiles, bool includeDirs, SearchOption searchOption) - // { - // return null; - - // /* - // //TODO: Add SearchOption functionality - // //TODO: What is userPathOriginal? - // //TODO: Add SearchPattern functionality - - // List xFileAndDirectoryNames = new List(); - - // //Validate input arguments - // if ((searchOption != SearchOption.TopDirectoryOnly) && (searchOption != SearchOption.AllDirectories)) - // throw new ArgumentOutOfRangeException("searchOption"); - - // searchPattern = searchPattern.TrimEnd(new char[0]); - // if (searchPattern.Length == 0) - // return new string[0]; - - // //Perform search in filesystem - // FilesystemEntry[] xEntries = GetDirectoryListing(path); - - // foreach (FilesystemEntry xEntry in xEntries) - // { - // if (xEntry.IsDirectory && includeDirs) - // xFileAndDirectoryNames.Add(xEntry.Name); - // else if (!xEntry.IsDirectory && includeFiles) - // xFileAndDirectoryNames.Add(xEntry.Name); - // } - - // return xFileAndDirectoryNames.ToArray(); - - // */ - // } - - // public static bool FileExists(string aPath) - // { - // try - // { - // FatHelpers.Debug("In VFSManager.FileExists"); - - // var xFile = VFSManager.TryGetFile(aPath); - // return (xFile != null); - // } - // catch (Exception E) - // { - // // don't ever remove this method, even if it doesn't contain any code! - // FatHelpers.Debug("Exception occurred in VFSManager.FileExists: "); - // // don't ever remove this method, even if it doesn't contain any code! - // FatHelpers.Debug(E.Message); - // return false; - // } - // } - - // public static bool DirectoryExists(string aPath) - // { - // try - // { - // FatHelpers.Debug("DirectoryExists. Path = '" + aPath + "'"); - // //xDir = Path.GetDirectoryName(xDir); - // FatHelpers.Debug("Before VFSManager.GetDirectory"); - - // var xDirectory = VFSManager.TryGetDirectory(aPath); - // if (xDirectory == null) - // { - // FatHelpers.Debug("Directory not found!"); - // FatHelpers.Debug(aPath); - // return false; - // } - // FatHelpers.Debug("Directory.Name:"); - // FatHelpers.Debug(xDirectory.Name); - // return (xDirectory != null); - // } - // catch (Exception E) - // { - // FatHelpers.Debug("Exception occurred in VFSManager.DirectoryExists: "); - // FatHelpers.Debug(E.Message); - // return false; - // } - - // } - - // public static Stream GetFileStream(string aPathname) - // { - // var xFileInfo = TryGetFile(aPathname); - // if (xFileInfo == null) - // { - // throw new Exception("File not found: " + aPathname); - // } - - // return xFileInfo.FileSystem.GetFileStream(xFileInfo); - // } - //} }