/// <inheritdocs /> public Stream OpenRead(string fileName) { //Find the file entry FileAllocationTableEntry entry = GetFileInfo(fileName); MemoryStream stream = new MemoryStream(); int remainingSize = entry.Size; bool firstCluster = true; foreach (int clusterId in entry.Clusters) { int position = ResolveClusterPosition(clusterId); int size = remainingSize < ClusterSize ? remainingSize : ClusterSize; if (firstCluster && _extensionsWithCRC.Contains(Path.GetExtension(fileName))) { position += 4; size -= 4; } byte[] buffer = _fileSystemData.Get(position, size); stream.Write(buffer); remainingSize -= buffer.Length; firstCluster = false; } stream.Position = 0; return(stream); }
/// <summary> /// Reads all the entries in a single partition /// </summary> /// <param name="reader">The reader used to read the partition entries from</param> /// <returns>An collection of <see cref="FileAllocationTableEntry" /></returns> protected virtual ICollection <FileAllocationTableEntry> ReadFileAllocationTable(BinaryReader reader) { IList <FileAllocationTableEntry> entries = new List <FileAllocationTableEntry>(); while (entries.Count < MaximumFATEntries) { FileAllocationTableEntry entry = ReadFATEntry(reader); if (entry == null) { break; } entries.Add(entry); } return(entries.ToArray()); }
/// <inheritdocs /> public void SaveFileInfo(FileAllocationTableEntry entry) { }