summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-io.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index 65e6a982a..a340b4c23 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -26,6 +26,7 @@
#include "wasm-io.h"
#include "support/debug.h"
+#include "support/path.h"
#include "wasm-binary.h"
#include "wasm-s-parser.h"
#include "wat-parser.h"
@@ -69,7 +70,10 @@ void ModuleReader::readBinaryData(std::vector<char>& input,
parser.setSkipFunctionBodies(skipFunctionBodies);
if (sourceMapFilename.size()) {
sourceMapStream = std::make_unique<std::ifstream>();
- sourceMapStream->open(sourceMapFilename);
+ sourceMapStream->open(wasm::Path::to_path(sourceMapFilename));
+ if (!sourceMapStream->is_open()) {
+ Fatal() << "Failed opening '" << sourceMapFilename << "'";
+ }
parser.setDebugLocations(sourceMapStream.get());
}
parser.read();
@@ -89,7 +93,7 @@ void ModuleReader::readBinary(std::string filename,
bool ModuleReader::isBinaryFile(std::string filename) {
std::ifstream infile;
std::ios_base::openmode flags = std::ifstream::in | std::ifstream::binary;
- infile.open(filename, flags);
+ infile.open(wasm::Path::to_path(filename), flags);
char buffer[4] = {1, 2, 3, 4};
infile.read(buffer, 4);
infile.close();
@@ -157,7 +161,11 @@ void ModuleWriter::writeBinary(Module& wasm, Output& output) {
std::unique_ptr<std::ofstream> sourceMapStream;
if (sourceMapFilename.size()) {
sourceMapStream = std::make_unique<std::ofstream>();
- sourceMapStream->open(sourceMapFilename);
+ sourceMapStream->open(wasm::Path::to_path(sourceMapFilename));
+ if (!sourceMapStream->is_open()) {
+ Fatal() << "Failed opening sourcemap output file '" << sourceMapFilename
+ << "'";
+ }
writer.setSourceMap(sourceMapStream.get(), sourceMapUrl);
}
if (symbolMap.size() > 0) {