コード例 #1
0
ファイル: DirectoryEntry.cs プロジェクト: ReinhardHsu/Cosmos
 protected DirectoryEntry(FileSystem aFileSystem, DirectoryEntry aParent, string aName, ulong aSize, DirectoryEntryTypeEnum aEntryType)
 {
     mFileSystem = aFileSystem;
     mParent = aParent;
     mEntryType = aEntryType;
     mName = aName;
     mSize = aSize;
 }
コード例 #2
0
ファイル: CosmosVFS.cs プロジェクト: rebizu/Cosmos
        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);
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
ファイル: FileSystem.cs プロジェクト: Zino2201/Cosmos
 public abstract void DeleteFile(DirectoryEntry aPath);
コード例 #5
0
ファイル: VFSManager.cs プロジェクト: vogon101/Cosmos
        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;
        }
コード例 #6
0
ファイル: FatFileSystem.cs プロジェクト: sajadbanooie/Cosmos
        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;
        }
コード例 #7
0
ファイル: CosmosVFS.cs プロジェクト: Zino2201/Cosmos
        /// <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);
        }
コード例 #8
0
ファイル: CosmosVFS.cs プロジェクト: Zino2201/Cosmos
        /// <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;
            }
        }
コード例 #9
0
ファイル: FatFileSystem.cs プロジェクト: bjuriewicz/Cosmos
        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;
        }
コード例 #10
0
ファイル: FileSystem.cs プロジェクト: Orvid/Cosmos
 public abstract DirectoryEntry CreateFile(DirectoryEntry aParentDirectory, string aNewFile);
コード例 #11
0
ファイル: FatFileSystem.cs プロジェクト: Zino2201/Cosmos
        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();
        }
コード例 #12
0
ファイル: FatFileSystem.cs プロジェクト: Zino2201/Cosmos
        public override void DeleteDirectory(DirectoryEntry aDirectoryEntry)
        {
            if(aDirectoryEntry == null)
            {
                throw new ArgumentNullException(nameof(aDirectoryEntry));
            }

            var xDirectoryEntry = (FatDirectoryEntry)aDirectoryEntry;

            xDirectoryEntry.DeleteDirectoryEntry();
        }
コード例 #13
0
ファイル: FileSystem.cs プロジェクト: sajadbanooie/Cosmos
 public abstract Stream GetFileStream(DirectoryEntry fileInfo);
コード例 #14
0
ファイル: FatFileSystem.cs プロジェクト: Anthilla/Cosmos
        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;
        }
コード例 #15
0
ファイル: FatFileSystem.cs プロジェクト: Anthilla/Cosmos
        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;
        }
コード例 #16
0
ファイル: VFSManager.cs プロジェクト: SUTD/Cosmos
        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);
        }
コード例 #17
0
ファイル: VFSManager.cs プロジェクト: SUTD/Cosmos
        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;
            }
        }
コード例 #18
0
ファイル: FileSystem.cs プロジェクト: Orvid/Cosmos
 public abstract List<DirectoryEntry> GetDirectoryListing(DirectoryEntry baseDirectory);
コード例 #19
0
ファイル: FileSystem.cs プロジェクト: Orvid/Cosmos
 public abstract DirectoryEntry CreateDirectory(DirectoryEntry aParentDirectory, string aNewDirectory);
コード例 #20
0
ファイル: FatFileSystem.cs プロジェクト: Orvid/Cosmos
        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;
        }
コード例 #21
0
ファイル: VFSManager.cs プロジェクト: Anthilla/Cosmos
        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;
        }
コード例 #22
0
ファイル: FatFileSystem.cs プロジェクト: Orvid/Cosmos
        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;
        }
コード例 #23
0
ファイル: FatFileSystem.cs プロジェクト: bjuriewicz/Cosmos
        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;
        }
コード例 #24
0
ファイル: VFSBase.cs プロジェクト: Zino2201/Cosmos
 public abstract bool DeleteDirectory(DirectoryEntry aPath);
コード例 #25
0
ファイル: CosmosVFS.cs プロジェクト: Zino2201/Cosmos
 /// <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;
     }
 }
コード例 #26
0
ファイル: VFSManager.cs プロジェクト: rebizu/Cosmos
        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;
        }
コード例 #27
0
ファイル: VFSManager.cs プロジェクト: rebizu/Cosmos
 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;
     }
 }
コード例 #28
0
ファイル: FatFileSystem.cs プロジェクト: sajadbanooie/Cosmos
        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;
        }
コード例 #29
0
ファイル: VFSManager.cs プロジェクト: vogon101/Cosmos
        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;
            }
        }
コード例 #30
0
ファイル: VFSManager.cs プロジェクト: sajadbanooie/Cosmos
        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);
        }