/// <summary> /// Will return a list of all pages in the block /// </summary> /// <returns></returns> public List <TPSPage> getPages() { RandomAccess ra = RandomAccess.GetInstance(); List <TPSPage> pages = new List <TPSPage>(); ra.jumpAbs(_start); //jump to the start of the block try{ while (ra.position < _end) //while we have not fallen off the end of the file { TPSPage page = new TPSPage(); page.Process(); pages.Add(page); //pages always start on the position % 100 = 0 //So let's jump forward to find the next start if ((ra.position & 0xFF) != 0x00) { ra.jumpAbs((ra.position & 0xFFFFFF00L) + 0x0100); } //we can find the next page because the address of the page will be in the data int addr = 0; if (!ra.isAtEnd()) { do { addr = ra.leLong(); ra.jumpRelative(-4); //backup 4 bytes if (addr != ra.position) { ra.jumpRelative(0x0100); } }while ((addr != ra.position) && !ra.isAtEnd()); } } }catch (Exception ex) { ; } return(pages); }
/// <summary> /// Returns all records of the page /// <returns></returns> public List <TPSRecord> GetRecords() { List <TPSRecord> records = new List <TPSRecord>(); byte[] pageData = GetData(); //go through each record in the page RandomAccess ra = new RandomAccess(); ra.OpenStream(new MemoryStream(pageData)); records.Clear(); // Skip pages with non 0x00 flags as they don't seem to contain TpsRecords. if (flags == 0x00) { //data.pushPosition(); try { TPSRecord prev = null; do { TPSRecord current = null; if (prev == null) { current = new TPSRecord(ref ra); } else { current = new TPSRecord(ref prev, ref ra); } records.Add(current); prev = current; } while (!ra.isAtEnd() && records.Count < recordCount); } finally { //data.popPosition(); } } return(records); }