From aa5f55985df95a853c30aecd21cde8c4663810d5 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Fri, 29 Jan 2016 03:55:59 -0800 Subject: tilesets --- tools/gbagfx/util.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tools/gbagfx/util.c') 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"); -- cgit v1.2.3