diff options
author | YamaArashi <shadow962@live.com> | 2016-01-29 03:55:59 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-01-29 03:55:59 -0800 |
commit | aa5f55985df95a853c30aecd21cde8c4663810d5 (patch) | |
tree | d08ef1b960ac66c41dbf89ddd2628c7b91e98d48 /tools/gbagfx/util.c | |
parent | 3a5e05377e844f62911633e7ff8da7a3d37cd2b2 (diff) |
tilesets
Diffstat (limited to 'tools/gbagfx/util.c')
-rw-r--r-- | tools/gbagfx/util.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/gbagfx/util.c b/tools/gbagfx/util.c index 5af380184..87abeb31c 100644 --- a/tools/gbagfx/util.c +++ b/tools/gbagfx/util.c @@ -84,6 +84,32 @@ unsigned char *ReadWholeFile(char *path, int *size) return buffer; } +unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount) +{ + FILE *fp = fopen(path, "rb"); + + if (fp == NULL) + FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); + + fseek(fp, 0, SEEK_END); + + *size = ftell(fp); + + unsigned char *buffer = calloc(*size + padAmount, 1); + + if (buffer == NULL) + FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); + + rewind(fp); + + if (fread(buffer, *size, 1, fp) != 1) + FATAL_ERROR("Failed to read \"%s\".\n", path); + + fclose(fp); + + return buffer; +} + void WriteWholeFile(char *path, void *buffer, int bufferSize) { FILE *fp = fopen(path, "wb"); |