public void ReadRecords(FileStream fs, PVD pvd) { var address = LBA * pvd.LogicBlockSize; fs.Seek(address, SeekOrigin.Begin); int last = (int)DataLength; while (last > 0) { var rec = new DirectoryRecord(); rec.Parent = this; var p0 = fs.Position; if (!rec.Parse(fs, pvd)) { var l = pvd.LogicBlockSize - p0 % pvd.LogicBlockSize; if (l < 100) { continue; } break; } Records.Add(rec); var p1 = fs.Position; var len = p1 - p0; last -= (int)len; } }
public static List <DirectoryRecord> GetAllRecords(DirectoryRecord rec, List <DirectoryRecord> records = null) { if (records == null) { records = new List <DirectoryRecord>(); } records.Add(rec); foreach (var directoryRecord in rec.Records) { GetAllRecords(directoryRecord, records); } return(records); }
public void Parse(FileStream fs) { Address = fs.Position; byte[] pvd = new byte[0x800]; fs.Read(pvd, 0, 0x800); Type = pvd[0]; var lbs = BitConverter.ToUInt16(pvd, 128); fs.Seek(Address + 156, SeekOrigin.Begin); RootDir = new DirectoryRecord(); RootDir.Parse(fs, this); LogicBlockSize = lbs; fs.Seek(Address + 0x800, SeekOrigin.Begin); }
public void Parse(FileStream fs) { fs.Seek(0x8000, SeekOrigin.Begin); List <PVD> list = new List <PVD>(); PVD p; while (true) { p = new PVD(); p.Parse(fs); if (p.Type == 0xff) { break; } list.Add(p); } DirectoryRecord.ReadRecursive(fs, list.Last().RootDir, list.Last()); Pvds = list.ToArray(); }
public static void ReadRecursive(FileStream fs, DirectoryRecord rec, PVD pvdd) { rec.ReadRecords(fs, pvdd); foreach (var directoryRecord in rec.Records) { if (directoryRecord.LBA == rec.LBA) { continue; } if (rec.Parent != null && directoryRecord.LBA == rec.Parent.LBA) { continue; } if (directoryRecord.IsDirectory) { ReadRecursive(fs, directoryRecord, pvdd); } else { //directoryRecord.ReadFile(fs, pvdd); } } }