diff options
author | Alon Zakai <azakai@mozilla.com> | 2011-01-16 13:52:25 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2011-01-16 13:52:25 -0800 |
commit | 6a6e842688afe7e15f6a957d4179da982c0f940b (patch) | |
tree | 9f31de60b019df0c8c6b0ca23d0ba963e2b1ed76 /tests/files.cpp | |
parent | 9d209878f9819ffd1aa92c7306123392609db845 (diff) |
initial emulation for stdio file reading, and other preparations for poppler
Diffstat (limited to 'tests/files.cpp')
-rw-r--r-- | tests/files.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/files.cpp b/tests/files.cpp new file mode 100644 index 00000000..a07ef42b --- /dev/null +++ b/tests/files.cpp @@ -0,0 +1,33 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +int main() { + FILE *file = fopen("somefile.binary", "rb"); + assert(file); + + fseek(file, 0, SEEK_END); + int size = ftell(file); + rewind (file); + printf("size: %d\n", size); + + char *buffer = (char*) malloc (sizeof(char)*size); + assert(buffer); + + size_t read = fread(buffer, 1, size, file); + assert(read == size); + + printf("data: %d", buffer[0]); + for (int i = 1; i < size; i++) + printf(",%d", buffer[i]); + printf("\n"); + + fclose (file); + free (buffer); + + fwrite("texto\n", 1, 6, stdout); + fwrite("texte\n", 1, 6, stderr); + + return 0; +} + |