summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/File.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/OSSupport/File.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index f860c37ca..113acc3a5 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -6,7 +6,6 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "File.h"
-#include <fstream>
#include <sys/stat.h>
#ifdef _WIN32
#include <share.h> // for _SH_DENYWRITE
@@ -710,3 +709,29 @@ void cFile::Flush(void)
{
fflush(m_File);
}
+
+
+
+
+
+template <class StreamType>
+FileStream<StreamType>::FileStream(const std::string & Path) :
+ StreamType()
+{
+ // Except on failbit, which is what open sets on failure:
+ FileStream::exceptions(FileStream::failbit | FileStream::badbit);
+
+ // Open the file:
+ FileStream::open(Path);
+
+ // Only subsequently except on serious errors, and not on conditions like EOF or malformed input:
+ FileStream::exceptions(FileStream::badbit);
+}
+
+
+
+
+
+// Instantiate the templated wrapper for input and output:
+template class FileStream<std::ifstream>;
+template class FileStream<std::ofstream>;