/// <summary> /// Gets data from the page /// If the page is compressed, it will uncompress it and return it. /// </summary> /// <returns></returns> private byte[] GetData() { //set our Randomaccess to the start of this page RandomAccess ra = RandomAccess.GetInstance(); byte[] pageData; ra.jumpAbs(addr); ra.jumpRelative(13); //skip the header //pull the page data //This really shouldn't be very big.. on my files it was about 8kb //If the file is using compression... uncompress it if ((pageSize != pageSizeUncompressed) && (flags == 0)) { try { pageData = ra.deRle(pageSize - 13); } catch (Exception ex) { throw new Exception("Bad RLE DataBlock ( compressed: " + pageSize + " uncompressed: " + pageSizeUncompressed + " Page Address: " + addr + "Record Count: " + recordCount.ToString() + "): ", ex); } } else { pageData = ra.leBytes(pageSize - 13); } return(pageData); }
/// <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); }
public void Process() { RandomAccess ra = RandomAccess.GetInstance(); addr = ra.leLong(); pageSize = ra.leShort(); pageSizeUncompressed = ra.leShort(); pageSizeUncompressedWithoutHeader = ra.leShort(); recordCount = ra.leShort(); flags = (int)ra.leByte(); ra.jumpRelative(pageSize - 13); //burn these bytes. This will leave the RandomAccess at the very end of the page }