public byte[] ReadAllBytes(string filePath) { FileEntry file = null; foreach (var entry in IndexAria) { if (entry is FileEntry fe) { if (fe.Name == filePath) { file = fe; } } } if (file == null) { return(null); } var buf = new List <byte>(); BlockBuffer.Offset = file.StartingBlock * BlockDevice.BlockSize; for (int i = 0; i < file.Length; i++) { buf.Add(BlockBuffer.ReadByte()); } return(buf.ToArray()); }
private void ReadIndexAria() { IndexAria.Clear(); var endOfVolume = BlockDevice.BlockSize * BlockDevice.TotalBlocks; var offset = 1; while (endOfVolume > offset * 64) { BlockBuffer.Offset = endOfVolume - offset * 64; var id = BlockBuffer.ReadByte(); BlockBuffer.Offset--; switch (id) { case 0x01: // VolumeIdentifier { var x = new VolumeIdentifier(); x.Read(BlockBuffer); IndexAria.Add(x); } break; case 0x02: // Starting Marker Entry { var x = new StartingMarkerEntry(); x.Read(BlockBuffer); IndexAria.Add(x); return; } case 0x10: // Unused Entry { var x = new UnusedEntry(); x.Read(BlockBuffer); IndexAria.Add(x); } break; case 0x11: // Directory Entry { var x = new DirectoryEntry(); x.Read(BlockBuffer); IndexAria.Add(x); if (x.Continuations > 0) { offset += x.Continuations + 1; BlockBuffer.Offset = endOfVolume - offset * 64; x.Name = BlockBuffer.ReadString(); } } break; case 0x12: // File Entry { var x = new FileEntry(); x.Read(BlockBuffer); IndexAria.Add(x); if (x.Continuations > 0) { offset += x.Continuations + 1; BlockBuffer.Offset = endOfVolume - offset * 64; x.Name = BlockBuffer.ReadString(); } } break; case 0x18: // Unusable Entry { var x = new UnusableEntry(); x.Read(BlockBuffer); IndexAria.Add(x); } break; case 0x19: // Deleted Directory Entry { var x = new DeletedDirectoryEntry(); x.Read(BlockBuffer); IndexAria.Add(x); if (x.Continuations > 0) { offset += x.Continuations + 1; BlockBuffer.Offset = endOfVolume - offset * 64; x.Name = BlockBuffer.ReadString(); } } break; case 0x1A: // Deleted File Entry { var x = new DeletedFileEntry(); x.Read(BlockBuffer); IndexAria.Add(x); if (x.Continuations > 0) { offset += x.Continuations + 1; BlockBuffer.Offset = endOfVolume - offset * 64; x.Name = BlockBuffer.ReadString(); } } break; } offset++; } }