Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to prepend data to an file without rewriting?

I deal with very large binary files ( several GB to multiple TB per file ). These files exist in a legacy format and upgrading requires writing a header to the FRONT of the file. I can create a new file and rewrite the data but sometimes this can take a long time. I'm wondering if there is any faster way to accomplish this upgrade. The platform is limited to Linux and I'm willing to use low-level functions (ASM, C, C++) / file system tricks to make this happen. The primimary library is Java and JNI is completely acceptable.

like image 350
basszero Avatar asked Jan 30 '11 17:01

basszero


1 Answers

There's no general way to do this natively.

Maybe some file-systems provide some functions to do this (cannot give any hint about this), but your code will then be file-system dependent.


A solution could be that of simulating a file-system: you could store your data on a set of several files, and then provide some functions to open, read and write data as if it was a single file.

like image 140
peoro Avatar answered Sep 24 '22 07:09

peoro