From 6a928b1280347619718c7faa86623123fbc34f30 Mon Sep 17 00:00:00 2001 From: Rob Conde Date: Tue, 6 Sep 2016 13:14:59 -0400 Subject: [PATCH] - fix Issue 13 where opening a file would throw an exception if the stream was set to throw exceptions on error --- core/lib/FileHandling/FFStream.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/lib/FileHandling/FFStream.cpp b/core/lib/FileHandling/FFStream.cpp index 7e6af0615..875de68f7 100644 --- a/core/lib/FileHandling/FFStream.cpp +++ b/core/lib/FileHandling/FFStream.cpp @@ -112,7 +112,12 @@ namespace gpstk void FFStream :: init( const char* fn, std::ios::openmode mode ) { - close(); + //close will fail if the stream is not currently open + //This will throw an exception is the fstream is set to + //throw exceptions on failures (exceptions(ifstream::failbit)) + if(is_open()) + close(); + clear(); filename = std::string(fn); recordNumber = 0;