From be13d761e772f270526b271559ef9c438b8d4221 Mon Sep 17 00:00:00 2001 From: bjorn Date: Mon, 7 Nov 2016 22:20:39 -0800 Subject: [PATCH] Clean up util; --- src/util.c | 35 ----------------------------------- src/util.h | 2 -- 2 files changed, 37 deletions(-) diff --git a/src/util.c b/src/util.c index d73b1d30..91a6395b 100644 --- a/src/util.c +++ b/src/util.c @@ -1,14 +1,7 @@ #include "util.h" #include -#include #include #include -#include -#ifdef __APPLE__ -#include -#else -#include -#endif void error(const char* format, ...) { va_list args; @@ -19,34 +12,6 @@ void error(const char* format, ...) { exit(EXIT_FAILURE); } -int fileExists(char* filename) { - return access(filename, 0) != -1; -} - -char* loadFile(char* filename) { - struct stat info; - - if (stat(filename, &info)) { - error("Could not stat '%s'", filename); - } - - int size = (int)info.st_size; - char* buffer = malloc(size + 1); - - int fd = open(filename, O_RDONLY); - - if (fd < 0) { - error("Could not open '%s'", filename); - } - - if (read(fd, buffer, size) < 0) { - error("Could not read '%s'", filename); - } - - buffer[size] = '\0'; - return buffer; -} - int luaPreloadModule(lua_State* L, const char* key, lua_CFunction f) { lua_getglobal(L, "package"); lua_getfield(L, -1, "preload"); diff --git a/src/util.h b/src/util.h index c88c55a9..ad29dffb 100644 --- a/src/util.h +++ b/src/util.h @@ -12,8 +12,6 @@ typedef vec_t(unsigned int) vec_uint_t; #endif void error(const char* format, ...); -int fileExists(char* filename); -char* loadFile(char* filename); void luaRegisterModule(lua_State* L, const char* name, const luaL_Reg* module); void luaRegisterType(lua_State* L, const char* name, const luaL_Reg* functions, lua_CFunction gc); int luaPreloadModule(lua_State* L, const char* key, lua_CFunction f);