Inheritance: SharpOS.Kernel.FileSystem.GenericFileSystem
示例#1
0
文件: FAT.cs 项目: willvin313/SharpOS
            public bool Compare(byte[] data, uint offset, FATType type)
            {
                BinaryFormat entry = new BinaryFormat(data);

                byte first = entry.GetByte(offset + Entry.DOSName);

                if (first == FileNameAttribute.LastEntry)
                {
                    return(false);
                }

                if ((first == FileNameAttribute.Deleted) | (first == FileNameAttribute.Dot))
                {
                    return(false);
                }

                if (first == FileNameAttribute.Escape)
                {
                    return(false);
                }

                string entryname = FAT.ExtractFileName(data, offset);

                if (entryname == name)
                {
                    return(true);
                }

                return(false);
            }
示例#2
0
文件: FAT.cs 项目: willvin313/SharpOS
            public bool Compare(byte[] data, uint offset, FATType type)
            {
                BinaryFormat entry = new BinaryFormat(data);

                byte first = entry.GetByte(offset + Entry.DOSName);

                if (first == FileNameAttribute.LastEntry)
                {
                    return(false);
                }

                if ((first == FileNameAttribute.Deleted) | (first == FileNameAttribute.Dot))
                {
                    return(false);
                }

                if (first == FileNameAttribute.Escape)
                {
                    return(false);
                }

                uint startcluster = FAT.GetClusterEntry(data, offset, type);

                if (startcluster == cluster)
                {
                    return(true);
                }

                return(false);
            }
示例#3
0
        public override void Delete(IVfsNode child, DirectoryEntry dentry)
        {
            FAT fs = this.FileSystem as FAT;

            uint childBlock = (child as VfsDirectory).directoryCluster;

            FAT.DirectoryEntryLocation location = fs.FindEntry(new FAT.FatMatchClusterComparer(childBlock), this.directoryCluster);

            if (!location.Valid)
            {
                throw new System.ArgumentException();                  //throw new IOException ("Unable to delete directory because it is not empty");
            }
            fs.Delete(childBlock, directoryCluster, location.DirectoryIndex);
        }
示例#4
0
		public FATFileStream (FAT fs, uint startCluster, uint directorySector, uint directoryIndex)
		{
			this.fs = fs;
			this.clusterSize = fs.ClusterSizeInBytes;
			this.data = new byte[clusterSize];
			this.startCluster = startCluster;
			this.directorySector = directorySector;
			this.directoryIndex = directoryIndex;
			this.read = true;
			this.write = false;
			this.position = -1;
			this.dirty = false;
			
			this.nthCluster = UInt32.MaxValue; // Not positioned yet 

			this.lengthOnDisk = fs.GetFileSize (directorySector, directoryIndex);
			this.length = this.lengthOnDisk;

			if (length != 0)
				ReadCluster (startCluster);
		}
示例#5
0
        public FATFileStream(FAT fs, uint startCluster, uint directorySector, uint directoryIndex)
        {
            this.fs              = fs;
            this.clusterSize     = fs.ClusterSizeInBytes;
            this.data            = new byte[clusterSize];
            this.startCluster    = startCluster;
            this.directorySector = directorySector;
            this.directoryIndex  = directoryIndex;
            this.read            = true;
            this.write           = false;
            this.position        = -1;
            this.dirty           = false;

            this.nthCluster = UInt32.MaxValue;             // Not positioned yet

            this.lengthOnDisk = fs.GetFileSize(directorySector, directoryIndex);
            this.length       = this.lengthOnDisk;

            if (length != 0)
            {
                ReadCluster(startCluster);
            }
        }
示例#6
0
文件: FAT.cs 项目: sharpos/SharpOS
		public DirectoryEntryLocation FindEntry (FAT.ICompare compare, uint startCluster)
		{
			uint activeSector = (startCluster == 0) ? firstRootDirectorySector : (startCluster * this.sectorsPerCluster);
			uint increment = 0;

			for (; ; ) {
				BinaryFormat directory = new BinaryFormat (partition.ReadBlock (activeSector, 1));

				for (uint index = 0; index < entriesPerSector; index++) {
					if (directory.GetByte ((index * Entry.EntrySize) + Entry.DOSName) == FileNameAttribute.LastEntry)
						return new DirectoryEntryLocation ();

					FileAttributes attribute = (FileAttributes)directory.GetByte ((index * Entry.EntrySize) + Entry.FileAttributes);

					if (compare.Compare (directory.Data, index * 32, fatType))
						return new DirectoryEntryLocation (GetClusterEntry (directory.Data, index, fatType), activeSector, index, (attribute & FileAttributes.SubDirectory) != 0);
				}

				++increment;

				if (startCluster == 0) {
					// root directory
					if (increment >= rootDirSectors)
						return new DirectoryEntryLocation ();

					activeSector = startCluster + increment;
					continue;
				}
				else {
					// subdirectory
					if (increment < sectorsPerCluster) {
						// still within cluster
						activeSector = startCluster + increment;
						continue;
					}
					// exiting cluster

					// goto next cluster (if any)
					uint cluster = GetClusterBySector (startCluster);

					if (cluster == 0)
						return new DirectoryEntryLocation ();

					uint nextCluster = GetClusterEntryValue (cluster);

					if ((IsClusterLast (nextCluster)) || (IsClusterBad (nextCluster)) || (IsClusterFree (nextCluster)) || (IsClusterReserved (nextCluster)))
						return new DirectoryEntryLocation ();

					activeSector = (uint)(dataAreaStart + (nextCluster - 1 * sectorsPerCluster));

					continue;
				}
			}
		}
示例#7
0
 public VfsFileSystem(FAT fat)
 {
     this.fat = fat;
 }
示例#8
0
		public VfsFileSystem (FAT fat)
		{
			this.fat = fat;
		}