示例#1
0
        /// <summary>
        /// Called to delete a child from a directory.
        /// </summary>
        /// <param name="child">The IVfsNode interface of the child.</param>
        /// <param name="dentry">The DirectoryEntry of the child.</param>
        /// <remarks>
        /// This function deletes a child IVfsNode from a directory. If child is a directory, it will be empty
        /// before this call is executed. It is recommended to include a debug sanity check though. If the file
        /// system needs to know the name of the child to delete, it can retrieve it from <see cref="DirectoryEntry.Name"/>.
        /// </remarks>
        /// <exception cref="System.NotSupportedException">The object does not support removal this way. There's most likely an object specific API to remove this IVfsNode.</exception>
        public override void Delete(IVfsNode child, DirectoryEntry dentry)
        {
            FatFileSystem fs = this.FileSystem as FatFileSystem;

            uint targetCluster = (child as VfsDirectory).directoryCluster;

            FatFileLocation location = fs.FindEntry(new Find.ByCluster(targetCluster), this.directoryCluster);

            if (!location.Valid)
            {
                throw new System.ArgumentException();                 //throw new IOException ("Unable to delete directory because it is not empty");
            }
            fs.Delete(targetCluster, location.DirectorySector, location.DirectorySectorIndex);
        }
示例#2
0
        /// <summary>
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public override IVfsNode Lookup(string name)
        {
            FatFileLocation location = (FileSystem as VfsFileSystem).FAT.FindEntry(new Find.WithName(name), this.directoryCluster);

            if (!location.Valid)
            {
                return(null);
            }

            if (location.IsDirectory)
            {
                return(new VfsDirectory(FileSystem, location.FirstCluster));
            }
            else
            {
                return(new VfsFile(FileSystem, location.FirstCluster, location.DirectorySector, location.DirectorySectorIndex));
            }
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FatFileStream"/> class.
 /// </summary>
 /// <param name="fs">The fs.</param>
 /// <param name="location">The location.</param>
 public FatFileStream(FatFileSystem fs, FatFileLocation location)
     : this(fs, location.FirstCluster, location.DirectorySector, location.DirectorySectorIndex)
 {
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FatFileStream"/> class.
 /// </summary>
 /// <param name="fs">The fs.</param>
 /// <param name="location">The location.</param>
 public FatFileStream(FatFileSystem fs, FatFileLocation location)
     : this(fs, location.FirstCluster, location.DirectorySector, location.DirectorySectorIndex)
 {
 }