/// <summary> /// Attempts to get a directory entry for a path in a file system. /// </summary> /// <param name="aPath">The path.</param> /// <param name="aFS">The file system.</param> /// <returns>A directory entry for the path.</returns> /// <exception cref="ArgumentNullException">aFS</exception> /// <exception cref="Exception">Path part ' + xPathPart + ' not found!</exception> private DirectoryEntry DoGetDirectoryEntry(string aPath, FileSystem aFS) { Global.mFileSystemDebugger.SendInternal("CosmosVFS.DoGetDirectoryEntry:"); if (String.IsNullOrEmpty(aPath)) { throw new ArgumentException("Argument is null or empty", nameof(aPath)); } if (aFS == null) { throw new ArgumentNullException(nameof(aFS)); } Global.mFileSystemDebugger.SendInternal("aPath ="); Global.mFileSystemDebugger.SendInternal(aPath); string[] xPathParts = VFSManager.SplitPath(aPath); DirectoryEntry xBaseDirectory = GetVolume(aFS); if (xPathParts.Length == 1) { Global.mFileSystemDebugger.SendInternal("Returning the volume."); return(xBaseDirectory); } // start at index 1, because 0 is the volume for (int i = 1; i < xPathParts.Length; i++) { var xPathPart = xPathParts[i].ToLower(); Global.mFileSystemDebugger.SendInternal("xPathPart ="); Global.mFileSystemDebugger.SendInternal(xPathPart); var xPartFound = false; var xListing = aFS.GetDirectoryListing(xBaseDirectory); for (int j = 0; j < xListing.Count; j++) { var xListingItem = xListing[j]; string xListingItemName = xListingItem.mName.ToLower(); xPathPart = xPathPart.ToLower(); Global.mFileSystemDebugger.SendInternal("xListingItemName ="); Global.mFileSystemDebugger.SendInternal(xListingItemName); if (xListingItemName == xPathPart) { Global.mFileSystemDebugger.SendInternal("Found path part."); xBaseDirectory = xListingItem; xPartFound = true; } } if (!xPartFound) { throw new Exception("Path part '" + xPathPart + "' not found!"); } } return(xBaseDirectory); }
private Directory DoGetDirectory(string aPath, Cosmos.System.FileSystem.FileSystem aFS) { if (aFS == null) { throw new Exception("File system can not be null."); } FatHelpers.Debug("In SentinelVFS.DoGetDirectory"); FatHelpers.Debug("Path = " + aPath); string[] xPathParts = VFSManager.SplitPath(aPath); if (xPathParts.Length == 1) { return(GetVolume(aFS, aPath)); } Directory xBaseDirectory = null; // start at index 1, because 0 is the volume for (int i = 1; i < xPathParts.Length; i++) { var xPathPart = xPathParts[i]; var xPartFound = false; var xListing = aFS.GetDirectoryListing(xBaseDirectory); for (int j = 0; j < xListing.Count; j++) { var xListingItem = xListing[j]; if (String.Equals(xListingItem.Name, xPathPart, StringComparison.OrdinalIgnoreCase)) { if (xListingItem is Directory) { xBaseDirectory = (Directory)xListingItem; xPartFound = true; } else { throw new Exception("Path part '" + xPathPart + "' found, but not a directory!"); } } } if (!xPartFound) { throw new Exception("Path part '" + xPathPart + "' not found!"); } } return(xBaseDirectory); }
private DirectoryEntry DoGetDirectoryEntry(string aPath, FileSystem aFS) { if (aFS == null) { throw new ArgumentNullException("aFS"); } string[] xPathParts = VFSManager.SplitPath(aPath); if (xPathParts.Length == 1) { return(GetVolume(aFS)); } DirectoryEntry xBaseDirectory = null; // start at index 1, because 0 is the volume for (int i = 1; i < xPathParts.Length; i++) { var xPathPart = xPathParts[i]; var xPartFound = false; var xListing = aFS.GetDirectoryListing(xBaseDirectory); for (int j = 0; j < xListing.Count; j++) { var xListingItem = xListing[j]; if (string.Equals(xListingItem.mName, xPathPart, StringComparison.OrdinalIgnoreCase)) { xBaseDirectory = xListingItem; xPartFound = true; } } if (!xPartFound) { throw new Exception("Path part '" + xPathPart + "' not found!"); } } return(xBaseDirectory); }
private DirectoryEntry DoGetDirectory(string aPath, FileSystem aFS) { if (aFS == null) { throw new ArgumentNullException("aFS"); } string[] xPathParts = VFSManager.SplitPath(aPath); if (xPathParts.Length == 1) { return GetVolume(aFS); } DirectoryEntry xBaseDirectory = null; // start at index 1, because 0 is the volume for (int i = 1; i < xPathParts.Length; i++) { var xPathPart = xPathParts[i]; var xPartFound = false; var xListing = aFS.GetDirectoryListing(xBaseDirectory); for (int j = 0; j < xListing.Count; j++) { var xListingItem = xListing[j]; if (string.Equals(xListingItem.mName, xPathPart, StringComparison.OrdinalIgnoreCase)) { if (xListingItem.mEntryType == DirectoryEntryTypeEnum.Directory) { xBaseDirectory = xListingItem; xPartFound = true; } else { throw new Exception("Path part '" + xPathPart + "' found, but not a directory!"); } } } if (!xPartFound) { throw new Exception("Path part '" + xPathPart + "' not found!"); } } return xBaseDirectory; }
/// <summary> /// Attempts to get a directory entry for a path in a file system. /// </summary> /// <param name="aPath">The path.</param> /// <param name="aFS">The file system.</param> /// <returns>A directory entry for the path.</returns> /// <exception cref="ArgumentNullException">aFS</exception> /// <exception cref="Exception">Path part ' + xPathPart + ' not found!</exception> private DirectoryEntry DoGetDirectoryEntry(string aPath, FileSystem aFS) { Global.mFileSystemDebugger.SendInternal("CosmosVFS.DoGetDirectoryEntry:"); if (String.IsNullOrEmpty(aPath)) { throw new ArgumentException("Argument is null or empty", nameof(aPath)); } if (aFS == null) { throw new ArgumentNullException(nameof(aFS)); } Global.mFileSystemDebugger.SendInternal("aPath ="); Global.mFileSystemDebugger.SendInternal(aPath); string[] xPathParts = VFSManager.SplitPath(aPath); if (xPathParts.Length == 1) { Global.mFileSystemDebugger.SendInternal("Returning the volume."); return GetVolume(aFS); } DirectoryEntry xBaseDirectory = null; // start at index 1, because 0 is the volume for (int i = 1; i < xPathParts.Length; i++) { var xPathPart = xPathParts[i].ToLower(); Global.mFileSystemDebugger.SendInternal("xPathPart ="); Global.mFileSystemDebugger.SendInternal(xPathPart); var xPartFound = false; var xListing = aFS.GetDirectoryListing(xBaseDirectory); for (int j = 0; j < xListing.Count; j++) { var xListingItem = xListing[j]; string xListingItemName = xListingItem.mName.ToLower(); xPathPart = xPathPart.ToLower(); Global.mFileSystemDebugger.SendInternal("xListingItemName ="); Global.mFileSystemDebugger.SendInternal(xListingItemName); if (xListingItemName == xPathPart) { Global.mFileSystemDebugger.SendInternal("Found path part."); xBaseDirectory = xListingItem; xPartFound = true; } } if (!xPartFound) { throw new Exception("Path part '" + xPathPart + "' not found!"); } } return xBaseDirectory; }