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); }
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); }
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); }
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); }
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); } }
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; } } }
public VfsFileSystem(FAT fat) { this.fat = fat; }
public VfsFileSystem (FAT fat) { this.fat = fat; }