idx

C library providing a standard for (non-standard) 64-bit file indexing functions.
git clone git://src.gearsix.net/idx
Log | Files | Refs | Atom | README

test.c (349B)


      1 #include "idx.h"
      2 
      3 #include <assert.h>
      4 
      5 #define FSIZE 9327112 // around 4.4GB
      6 
      7 int main(int argc, char **argv)
      8 {
      9 	idx_t pos;
     10 	FILE *f;
     11 
     12 	f = tmpfile();
     13 	if (!f) return -1;
     14 
     15 	for (pos = 0; pos < FSIZE; ++pos)
     16 		fputc('.', f);
     17 	assert(pos == FSIZE);
     18 
     19 	idxseek(f, FSIZE / 2, SEEK_SET);
     20 	pos = ftell(f);
     21 	assert(pos == FSIZE / 2);
     22 
     23 	return fclose(f);
     24 }
     25