From 7019271bfebc10aad28dddb1647eef89bb67fd89 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Tue, 24 Jul 2018 17:13:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Move=20utility=20functions=20into?= =?UTF-8?q?=20separate=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 2 +- src/fileReader.c | 10 ++-------- src/{ => utils}/fileUtilities.c | 2 +- src/{ => utils}/fileUtilities.h | 2 -- src/utils/min.h | 5 +++++ 5 files changed, 9 insertions(+), 12 deletions(-) rename src/{ => utils}/fileUtilities.c (97%) rename src/{ => utils}/fileUtilities.h (94%) create mode 100644 src/utils/min.h diff --git a/build.sh b/build.sh index 3ea1d02..a6c7480 100644 --- a/build.sh +++ b/build.sh @@ -1 +1 @@ -gcc -m64 -o patcher-installer lib/miniz/*.c src/*.c && chmod +x patcher-installer +gcc -m64 -o patcher-installer lib/miniz/*.c src/*.c src/*/*.c && chmod +x patcher-installer diff --git a/src/fileReader.c b/src/fileReader.c index 573ad76..9daa167 100644 --- a/src/fileReader.c +++ b/src/fileReader.c @@ -4,14 +4,8 @@ #include #include "fileReader.h" -#include "fileUtilities.h" - -//minimum of two integers -#define min(a,b) \ - ({ __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a < _b ? _a : _b; }) - +#include "utils/fileUtilities.h" +#include "utils/min.h" //Opens the given file at the given offset void initFileReader(char path[], unsigned long offset) { diff --git a/src/fileUtilities.c b/src/utils/fileUtilities.c similarity index 97% rename from src/fileUtilities.c rename to src/utils/fileUtilities.c index 394594a..838c016 100644 --- a/src/fileUtilities.c +++ b/src/utils/fileUtilities.c @@ -4,7 +4,7 @@ #include #include "fileUtilities.h" -#include "fileReader.h" +#include "../fileReader.h" //Reads the given amount of bytes from the currently open file into the given buffer. diff --git a/src/fileUtilities.h b/src/utils/fileUtilities.h similarity index 94% rename from src/fileUtilities.h rename to src/utils/fileUtilities.h index 947ee8a..0fc68ef 100644 --- a/src/fileUtilities.h +++ b/src/utils/fileUtilities.h @@ -1,7 +1,5 @@ #pragma once -#include "fileReader.h" - //A structure to store various information needed when reading from a file. struct FILE_INFO { char* name; diff --git a/src/utils/min.h b/src/utils/min.h new file mode 100644 index 0000000..9605113 --- /dev/null +++ b/src/utils/min.h @@ -0,0 +1,5 @@ +//minimum of two integers +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; })