summaryrefslogtreecommitdiff
path: root/src/support/file.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-31 15:37:53 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-31 15:37:53 -0700
commit59972bd1b723d6a2441ef74d724b1355e07fea2f (patch)
tree68a82bf239e2d65f5d419ae6b208d5b1db754c63 /src/support/file.cpp
parentd0ae4a2d778a92be712d3f510f94273bb3e394da (diff)
downloadbinaryen-59972bd1b723d6a2441ef74d724b1355e07fea2f.tar.gz
binaryen-59972bd1b723d6a2441ef74d724b1355e07fea2f.tar.bz2
binaryen-59972bd1b723d6a2441ef74d724b1355e07fea2f.zip
refactor file flags into enums
Diffstat (limited to 'src/support/file.cpp')
-rw-r--r--src/support/file.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/support/file.cpp b/src/support/file.cpp
index 0ec460041..b71361d99 100644
--- a/src/support/file.cpp
+++ b/src/support/file.cpp
@@ -20,11 +20,11 @@
#include <limits>
template <typename T>
-T wasm::read_file(const std::string &filename, bool binary, bool debug) {
- if (debug) std::cerr << "Loading '" << filename << "'..." << std::endl;
+T wasm::read_file(const std::string &filename, Flags::BinaryOption binary, Flags::DebugOption debug) {
+ if (debug == Flags::Debug) std::cerr << "Loading '" << filename << "'..." << std::endl;
std::ifstream infile;
auto flags = std::ifstream::in;
- if (binary) flags |= std::ifstream::binary;
+ if (binary == Flags::Binary) flags |= std::ifstream::binary;
infile.open(filename, flags);
if (!infile.is_open()) {
std::cerr << "Failed opening '" << filename << "'" << std::endl;
@@ -44,16 +44,16 @@ T wasm::read_file(const std::string &filename, bool binary, bool debug) {
}
// Explicit instantiations for the explicit specializations.
-template std::string wasm::read_file<>(const std::string &, bool, bool);
-template std::vector<char> wasm::read_file<>(const std::string &, bool, bool);
+template std::string wasm::read_file<>(const std::string &, Flags::BinaryOption, Flags::DebugOption);
+template std::vector<char> wasm::read_file<>(const std::string &, Flags::BinaryOption, Flags::DebugOption);
-wasm::Output::Output(const std::string &filename, bool binary, bool debug)
+wasm::Output::Output(const std::string &filename, Flags::BinaryOption binary, Flags::DebugOption debug)
: outfile(), out([this, filename, binary, debug]() {
std::streambuf *buffer;
if (filename.size()) {
- if (debug) std::cerr << "Opening '" << filename << std::endl;
+ if (debug == Flags::Debug) std::cerr << "Opening '" << filename << std::endl;
auto flags = std::ofstream::out | std::ofstream::trunc;
- if (binary) flags |= std::ofstream::binary;
+ if (binary == Flags::Binary) flags |= std::ofstream::binary;
outfile.open(filename, flags);
if (!outfile.is_open()) {
std::cerr << "Failed opening '" << filename << "'" << std::endl;