protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aName, ulong aSize, DirectoryEntryTypeEnum aEntryType) { mFileSystem = aFileSystem; mParent = aParent; mEntryType = aEntryType; mName = aName; mSize = aSize; }
public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry aDirectory) { DirectoryEntry xTempEntry = aDirectory; string xFullPath = ""; while (xTempEntry.mParent != null) { xFullPath = Path.Combine(xTempEntry.mName, xFullPath); xTempEntry = xTempEntry.mParent; } return GetDirectoryListing(xFullPath); }
/// <summary> /// Initializes a new instance of the <see cref="DirectoryEntry"/> class. /// </summary> /// <param name="aFileSystem">The file system that contains the directory entry.</param> /// <param name="aParent">The parent directory entry or null if the current entry is the root.</param> /// <param name="aFullPath">The full path to the entry.</param> /// <param name="aName">The entry name.</param> /// <param name="aSize">The size of the entry.</param> /// <param name="aEntryType">The ype of the entry.</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"> /// Argument is null or empty /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// </exception> protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aFullPath, string aName, long aSize, DirectoryEntryTypeEnum aEntryType) { if (aFileSystem == null) { throw new ArgumentNullException(nameof(aFileSystem)); } if (string.IsNullOrEmpty(aFullPath)) { throw new ArgumentException("Argument is null or empty", nameof(aFullPath)); } if (string.IsNullOrEmpty(aName)) { throw new ArgumentException("Argument is null or empty", nameof(aName)); } mFileSystem = aFileSystem; mParent = aParent; mEntryType = aEntryType; mName = aName; mSize = aSize; mFullPath = aFullPath; }
public abstract void DeleteFile(DirectoryEntry aPath);
public static string GetFullPath(DirectoryEntry aEntry) { Global.mFileSystemDebugger.SendInternal("VFSManager.GetFullPath:"); if (aEntry == null) { throw new ArgumentNullException(nameof(aEntry)); } Global.mFileSystemDebugger.SendInternal("aEntry.mName ="); Global.mFileSystemDebugger.SendInternal(aEntry.mName); var xParent = aEntry.mParent; string xPath = aEntry.mName; while (xParent != null) { xPath = xParent.mName + xPath; Global.mFileSystemDebugger.SendInternal("xPath ="); Global.mFileSystemDebugger.SendInternal(xPath); xParent = xParent.mParent; Global.mFileSystemDebugger.SendInternal("xParent.mName ="); Global.mFileSystemDebugger.SendInternal(xParent.mName); } Global.mFileSystemDebugger.SendInternal("xPath ="); Global.mFileSystemDebugger.SendInternal(xPath); return xPath; }
public override Stream GetFileStream(DirectoryEntry fileInfo) { if (fileInfo.EntryType == DirectoryEntryTypeEnum.File) { return new FatStream((FatDirectoryEntry)fileInfo); } FatHelpers.Debug("GetFileStream only works for file entries."); return null; }
/// <summary> /// Gets the directory listing for a directory entry. /// </summary> /// <param name="aDirectory">The directory entry.</param> /// <returns></returns> public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry aDirectory) { if (aDirectory == null || String.IsNullOrEmpty(aDirectory.mFullPath)) { throw new ArgumentException("Argument is null or empty", nameof(aDirectory)); } return GetDirectoryListing(aDirectory.mFullPath); }
/// <summary> /// Deletes an empty directory. /// </summary> /// <param name="aPath">The full path.</param> /// <returns></returns> public override bool DeleteDirectory(DirectoryEntry aPath) { try { if (GetDirectoryListing(aPath).Count > 0) throw new Exception("Directory is not empty"); var xFS = GetFileSystemFromPath(aPath.mFullPath); xFS.DeleteDirectory(aPath); return true; } catch { return false; } }
public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory) { Global.mFileSystemDebugger.SendInternal("-- FatFileSystem.GetDirectoryListing --"); if (baseDirectory == null) { throw new ArgumentNullException(nameof(baseDirectory)); } var result = new List<DirectoryEntry>(); var xEntry = (FatDirectoryEntry)baseDirectory; var fatListing = xEntry.ReadDirectoryContents(); for (int i = 0; i < fatListing.Count; i++) { result.Add(fatListing[i]); } return result; }
public abstract DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile);
public override void DeleteFile(DirectoryEntry aDirectoryEntry) { if (aDirectoryEntry == null) { throw new ArgumentNullException(nameof(aDirectoryEntry)); } var xDirectoryEntry = (FatDirectoryEntry)aDirectoryEntry; var entries = xDirectoryEntry.GetFatTable(); foreach (var entry in entries) { GetFat(0).ClearFatEntry(entry); } xDirectoryEntry.DeleteDirectoryEntry(); }
public override void DeleteDirectory(DirectoryEntry aDirectoryEntry) { if(aDirectoryEntry == null) { throw new ArgumentNullException(nameof(aDirectoryEntry)); } var xDirectoryEntry = (FatDirectoryEntry)aDirectoryEntry; xDirectoryEntry.DeleteDirectoryEntry(); }
public abstract Stream GetFileStream(DirectoryEntry fileInfo);
public override DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile) { if (aParentDirectory == null) { throw new ArgumentNullException("aParentDirectory"); } if (aNewFile == null) { throw new ArgumentNullException("aNewFile"); } if (string.IsNullOrWhiteSpace(aNewFile)) { throw new ArgumentException("The new file must be specified.", "aNewFile"); } FileSystemHelpers.Debug("FatFileSystem.CreateFile", "aParentDirectory.Name =", aParentDirectory?.mName, ", aNewFile =", aNewFile); var xParentDirectory = (FatDirectoryEntry)aParentDirectory; var xDirectoryEntryToAdd = xParentDirectory.AddDirectoryEntry(aNewFile, DirectoryEntryTypeEnum.File); return xDirectoryEntryToAdd; }
public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory) { FileSystemHelpers.Debug("FatFileSystem.GetDirectoryListing", "baseDirectory.Name =", baseDirectory?.mName); var result = new List<DirectoryEntry>(); List<FatDirectoryEntry> fatListing; if (baseDirectory == null) { // get root folder var xEntry = (FatDirectoryEntry)GetRootDirectory(); fatListing = xEntry.ReadDirectoryContents(); } else { var xEntry = (FatDirectoryEntry)baseDirectory; fatListing = xEntry.ReadDirectoryContents(); } for (int i = 0; i < fatListing.Count; i++) { result.Add(fatListing[i]); } return result; }
public static string GetFullPath(DirectoryEntry aEntry) { FatHelpers.Debug("-- VFSManager.GetFullPath --"); DirectoryEntry xEntry = aEntry; string xPath = string.Empty; while (xEntry != null) { xPath = xEntry + xEntry.Name; xEntry = aEntry.Parent; FatHelpers.Debug("-- VFSManager.GetFullPath : xPath = " + xPath + " --"); } return Path.GetFullPath(xPath); }
public static bool DirectoryExists(DirectoryEntry aEntry) { FatHelpers.Debug("-- VFSManager.DirectoryExists --"); try { string xPath = GetFullPath(aEntry); return GetDirectory(xPath) != null; } catch (Exception e) { global::System.Console.Write("Exception occurred: "); global::System.Console.WriteLine(e.Message); return false; } }
public abstract List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory);
public abstract DirectoryEntry CreateDirectory(DirectoryEntry aParentDirectory, string aNewDirectory);
public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory) { Global.mFileSystemDebugger.SendInternal($"FatFileSystem.GetDirectoryListing : baseDirectory.Name = {baseDirectory?.mName}"); var result = new List<DirectoryEntry>(); List<FatDirectoryEntry> fatListing; if (baseDirectory == null) { // get root folder var xEntry = (FatDirectoryEntry)GetRootDirectory(); fatListing = xEntry.ReadDirectoryContents(); } else { var xEntry = (FatDirectoryEntry)baseDirectory; fatListing = xEntry.ReadDirectoryContents(); } for (int i = 0; i < fatListing.Count; i++) { result.Add(fatListing[i]); } return result; }
public static string GetFullPath(DirectoryEntry aEntry) { FileSystemHelpers.Debug("VFSManager.GetFullPath : aEntry.mName = " + aEntry?.mName); var xParent = aEntry?.mParent; string xPath = aEntry?.mName; while (xParent != null) { xPath = xParent.mName + xPath; FileSystemHelpers.Debug("VFSManager.GetFullPath : xPath = " + xPath); xParent = xParent.mParent; } FileSystemHelpers.Debug("VFSManager.GetFullPath : xPath = " + xPath); return xPath; }
public override DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile) { if (aParentDirectory == null) { throw new ArgumentNullException("aParentDirectory"); } if (aNewFile == null) { throw new ArgumentNullException("aNewFile"); } if (string.IsNullOrWhiteSpace(aNewFile)) { throw new ArgumentException("The new file must be specified.", "aNewFile"); } Global.mFileSystemDebugger.SendInternal($"FatFileSystem.CreateFile : aParentDirectory.Name = {aParentDirectory?.mName}, aNewFile = {aNewFile}"); var xParentDirectory = (FatDirectoryEntry)aParentDirectory; var xDirectoryEntryToAdd = xParentDirectory.AddDirectoryEntry(aNewFile, DirectoryEntryTypeEnum.File); return xDirectoryEntryToAdd; }
public override DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile) { Global.mFileSystemDebugger.SendInternal("-- FatFileSystem.CreateFile --"); Global.mFileSystemDebugger.SendInternal("aParentDirectory.Name ="); Global.mFileSystemDebugger.SendInternal(aParentDirectory?.mName); Global.mFileSystemDebugger.SendInternal("aNewFile ="); Global.mFileSystemDebugger.SendInternal(aNewFile); if (aParentDirectory == null) { throw new ArgumentNullException(nameof(aParentDirectory)); } if (string.IsNullOrEmpty(aNewFile)) { throw new ArgumentNullException(nameof(aNewFile)); } var xParentDirectory = (FatDirectoryEntry)aParentDirectory; var xDirectoryEntryToAdd = xParentDirectory.AddDirectoryEntry(aNewFile, DirectoryEntryTypeEnum.File); return xDirectoryEntryToAdd; }
public abstract bool DeleteDirectory(DirectoryEntry aPath);
/// <summary> /// Deletes a file. /// </summary> /// <param name="aPath">The full path.</param> /// <returns></returns> public override bool DeleteFile(DirectoryEntry aPath) { try { var xFS = GetFileSystemFromPath(aPath.mFullPath); xFS.DeleteFile(aPath); return true; } catch { return false; } }
public static string GetFullPath(DirectoryEntry aEntry) { FileSystemHelpers.Debug("VFSManager.GetFullPath : aEntry.mName = " + aEntry?.mName); var xEntry = aEntry?.mParent; string xPath = aEntry?.mName; while (xEntry != null) { FileSystemHelpers.Debug("VFSManager.GetFullPath : xEntry is not null."); xPath = string.Concat(xPath, xEntry.mName); FileSystemHelpers.Debug("VFSManager.GetFullPath : xPath = " + xPath); xEntry = aEntry.mParent; } FileSystemHelpers.Debug("VFSManager.GetFullPath : xPath = " + xPath); return xPath; }
public static bool DirectoryExists(DirectoryEntry aEntry) { try { FileSystemHelpers.Debug("VFSManager.DirectoryExists", "aEntry.mName =", aEntry?.mName); string xPath = GetFullPath(aEntry); return GetDirectory(xPath) != null; } catch (Exception e) { global::System.Console.Write("Exception occurred: "); global::System.Console.WriteLine(e.Message); return false; } }
public override List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory) { List<DirectoryEntry> result = new List<DirectoryEntry>(); List<FatDirectoryEntry> fatListing = new List<FatDirectoryEntry>(); if (baseDirectory == null) { // get root folder fatListing = GetRoot(); } else { fatListing = GetDirectoryContents((FatDirectoryEntry)baseDirectory); } for (int i = 0; i < fatListing.Count; i++) { result.Add(fatListing[i]); } return result; }
public static bool DirectoryExists(DirectoryEntry aEntry) { Global.mFileSystemDebugger.SendInternal("VFSManager.DirectoryExists:"); if (aEntry == null) { throw new ArgumentNullException(nameof(aEntry)); } try { Global.mFileSystemDebugger.SendInternal("aEntry.mName ="); Global.mFileSystemDebugger.SendInternal(aEntry.mName); string xPath = GetFullPath(aEntry); Global.mFileSystemDebugger.SendInternal("After GetFullPath"); Global.mFileSystemDebugger.SendInternal("xPath ="); Global.mFileSystemDebugger.SendInternal(xPath); return GetDirectory(xPath) != null; } catch (Exception e) { global::System.Console.Write("Exception occurred: "); global::System.Console.WriteLine(e.Message); return false; } }
public static string GetFullPath(DirectoryEntry aEntry) { DirectoryEntry xEntry = aEntry; string xPath = string.Empty; while (xEntry != null) { xPath = xEntry + xEntry.Name; xEntry = aEntry.Parent; } return Path.GetFullPath(xPath); }