summaryrefslogtreecommitdiff
path: root/tools/gbagfx/util.c
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-01-29 03:55:59 -0800
committerYamaArashi <shadow962@live.com>2016-01-29 03:55:59 -0800
commitaa5f55985df95a853c30aecd21cde8c4663810d5 (patch)
treed08ef1b960ac66c41dbf89ddd2628c7b91e98d48 /tools/gbagfx/util.c
parent3a5e05377e844f62911633e7ff8da7a3d37cd2b2 (diff)
tilesets
Diffstat (limited to 'tools/gbagfx/util.c')
-rw-r--r--tools/gbagfx/util.c26
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");