diff options
author | lloyd <[email protected]> | 2010-09-08 14:26:01 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-08 14:26:01 +0000 |
commit | 0d2976da7bf4d389da6d1608d32e2c67fff13b4b (patch) | |
tree | 86626f54ff3d26f473773fbd051ac1f4a30a1b57 | |
parent | 831a353a582eadaf3f6e35d5cb8b4dc79662f33f (diff) |
Fix binary input in DataSource_Stream - the conditional was backwards.
Use a slightly cleaner invocation that doesn't require duplicating so much
code between the binary and non-binary cases.
-rw-r--r-- | src/filters/data_snk.cpp | 6 | ||||
-rw-r--r-- | src/filters/data_src.cpp | 15 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/filters/data_snk.cpp b/src/filters/data_snk.cpp index d61fcc61f..82ffddc53 100644 --- a/src/filters/data_snk.cpp +++ b/src/filters/data_snk.cpp @@ -40,9 +40,9 @@ DataSink_Stream::DataSink_Stream(std::ostream& out, DataSink_Stream::DataSink_Stream(const std::string& path, bool use_binary) : identifier(path), - sink_p(use_binary ? - new std::ofstream(path.c_str(), std::ios::binary) : - new std::ofstream(path.c_str())), + sink_p(new std::ofstream( + path.c_str(), + use_binary ? std::ios::binary : std::ios::out)), sink(*sink_p) { if(!sink.good()) diff --git a/src/filters/data_src.cpp b/src/filters/data_src.cpp index 522ce09d0..eceb0184a 100644 --- a/src/filters/data_src.cpp +++ b/src/filters/data_src.cpp @@ -171,18 +171,17 @@ std::string DataSource_Stream::id() const DataSource_Stream::DataSource_Stream(const std::string& path, bool use_binary) : identifier(path), - source_p(use_binary ? - new std::ifstream(path.c_str()) : - new std::ifstream(path.c_str(), std::ios::binary)), - source(*source_p) + source_p(new std::ifstream( + path.c_str(), + use_binary ? std::ios::binary : std::ios::in)), + source(*source_p), + total_read(0) { if(!source.good()) { delete source_p; throw Stream_IO_Error("DataSource: Failure opening file " + path); } - - total_read = 0; } /* @@ -192,9 +191,9 @@ DataSource_Stream::DataSource_Stream(std::istream& in, const std::string& name) : identifier(name), source_p(0), - source(in) + source(in), + total_read(0) { - total_read = 0; } /* |