javascript - How can I reposition offset addresses quickly? -


i have file information. each section of information located @ offset. there 100 sections of information. every section of information starts @ beginning of word "lps" @ beginning of file there list of offset addresses point each section of information.

for example:

"801f 0b00" link offset "b1f80" new section of information starts "80b0 0b00" refers offset "bb080" new section of information starts

i'm adding/shortening information of lines, need change offsets @ beginning of file (the list) make them coincide new locations.

so, code me automatically? example, tool must recognize offset addresses (the list) allow me add new information then, modify list of offset new locations.

thanks

lets assume file has 100 offsets , strings. once see how works change 100 variable.

to read file, this

#define n 100 typedef int offset;  // assume int 4 btyes , big enough hold file offset offset offset[ n ]; // offset[n-1] 1 past end of last data string // read n offsets file offset[]  std::string data[ n ]; for( int = 0; < n-1; i++ ) {     size_t len = offset[i+1] - offset[i] - 1;     // read 'len' bytes @ offset[i] data[i] } 

now make changes strings in data[] , want rewrite file. write new file this

offset[0] = sizeof(offset);   // start of data in file for( int = 1; < n; i++ ) {     offset[i] = offset[i-1] + data[i-1].size(); } // write offset[] array file  for( int = 0; < n-1; i++ ) {     // write data[i] @ offset[i] in file } 

good luck!


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -