From 7f3d00446d2b7090031bc6a0a1a3496f3b543bc8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Nov 2019 18:34:05 +0100 Subject: [PATCH] - removed the unused File* functions which were the last remaining places to use stdio FILE for reading. For writing FILE is mostly fine, but reading should exclusively use FileReader to ensure interoperability with the virtual file system. --- source/blood/src/misc.cpp | 34 ---------------------------------- source/blood/src/misc.h | 4 ---- 2 files changed, 38 deletions(-) diff --git a/source/blood/src/misc.cpp b/source/blood/src/misc.cpp index d494fc415..835f8328b 100644 --- a/source/blood/src/misc.cpp +++ b/source/blood/src/misc.cpp @@ -68,40 +68,6 @@ void *ResReadLine(char *buffer, unsigned int nBytes, void **pRes) return *pRes; } -bool FileRead(FILE *handle, void *buffer, unsigned int size) -{ - return fread(buffer, 1, size, handle) == size; -} - -bool FileWrite(FILE *handle, void *buffer, unsigned int size) -{ - return fwrite(buffer, 1, size, handle) == size; -} - -bool FileLoad(const char *name, void *buffer, unsigned int size) -{ - dassert(buffer != NULL); - - FILE *handle = fopen(name, "rb"); - if (!handle) - return false; - - unsigned int nread = fread(buffer, 1, size, handle); - fclose(handle); - return nread == size; -} - -int FileLength(FILE *handle) -{ - if (!handle) - return 0; - int nPos = ftell(handle); - fseek(handle, 0, SEEK_END); - int nLength = ftell(handle); - fseek(handle, nPos, SEEK_SET); - return nLength; -} - unsigned int randSeed = 1; unsigned int qrand(void) diff --git a/source/blood/src/misc.h b/source/blood/src/misc.h index 3763d4c7d..9d1c4985e 100644 --- a/source/blood/src/misc.h +++ b/source/blood/src/misc.h @@ -25,10 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS void *ResReadLine(char *buffer, unsigned int nBytes, void **pRes); -bool FileRead(FILE *, void *, unsigned int); -bool FileWrite(FILE *, void *, unsigned int); -bool FileLoad(const char *, void *, unsigned int); -int FileLength(FILE *); unsigned int qrand(void); int wrand(void); void wsrand(int);