---
Travis Rose
/*
Compile with: 'gcc -D_FILE_OFFSET_BITS=64 osx_mempb_tester.c -o
osx_mempb_tester'
(note: the define is here to insure it is ok to write files > 2GB [if you
change the end value of 'i'] and the problem still exist without it)
----------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main(int argc, char** argv)
{
int fdw;
size_t wrote;
unsigned char *data;
int towrite = 16*1024*1024;
int i=0;
data = "" 1);
// Init
//fdw = open("/tmp/testfile", O_RDWR|O_CREAT|O_TRUNC, 0666);
// Get a file pointer, open for writing, binary mode
FILE *myFile = fopen("testfile", "wb");
// write a 1GB file to disk (full of 0s)
while (i++ < 64)
{
int wrote;
printf("writing block: %i\n", i);
//wrote = write(fdw, data, towrite);
//size_t fwrite ( const void * buffer, size_t size, size_t count, FILE * stream );
//
//
wrote = fwrite(data, 1, towrite, myFile);
if (wrote != towrite)
{
printf("Expected %d / Wrote %d\n", towrite, wrote);
exit(1);
}
// flush buffer for this file
fflush( myFile);
}
//close(fdw);
fclose(myFile);
// Clean up
free(data);
return EXIT_SUCCESS;
}