title: Accessing Large Files In C
body: <p>I need to access a file larger than 2gb using C. During one run of the program a variable number of bytes will be read from the file and the location of the next position saved. During the next run of the program the file position is read and a number of bytes are read starting from that location.</p>
  
  <p>The complication is that occasionally the file may be 'compressed' by copying it to a new file, less any bytes that have already been read (I think copying is the only way to do that). The number of bytes removed in this way will also be saved.</p>
  
  <p>I need to know the current position of the file from the original start for synchronizing with another file. This should be easy because it is just (current_offset + deleted_bytes).</p>
  
  <p>The reason it is not easy is the fseek only uses long int indexes which limits the file to 2gb, and fsetpos uses an fpos_t structure for the position index, which is not a number and can't be converted back and forth to one. I don't know of any way to use a long long int index for file positioning, which would be the ideal solution.</p>
  
  <p>What do I do?</p>