From 9cc8bab102b47b7f8fd8ac77e6f629f7cff71b7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Dec 2017 11:55:50 +0100 Subject: [PATCH] - only have one fopen call in the entire FileReader hierarchy This is for an eventual implementation of UTF-8 handling. On Windows this will require replacement of fopen with _wfopen so let's try to keep the number of fopen calls low. --- src/files.cpp | 7 ++++++- src/files.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/files.cpp b/src/files.cpp index 5bcc3d7bb4..b42aefece5 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -50,6 +50,11 @@ // //========================================================================== +FILE *FileReader::openfd(const char *filename) +{ + return fopen(filename, "rb"); +} + FileReader::FileReader () : File(NULL), Length(0), StartPos(0), FilePos(0), CloseOnDestruct(false) { @@ -93,7 +98,7 @@ FileReader::~FileReader () bool FileReader::Open (const char *filename) { - File = fopen (filename, "rb"); + File = openfd (filename); if (File == NULL) return false; FilePos = 0; StartPos = 0; diff --git a/src/files.h b/src/files.h index 94255b1a0b..d0c769ba15 100644 --- a/src/files.h +++ b/src/files.h @@ -93,6 +93,8 @@ public: class FileReader : public FileReaderBase { +protected: + FILE *openfd(const char *filename); public: FileReader (); FileReader (const char *filename);