summaryrefslogtreecommitdiff
path: root/src/support/file.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-09-01 12:34:03 -0700
committerGitHub <noreply@github.com>2017-09-01 12:34:03 -0700
commit6de14693110b4f898344ff1cb383caf0d74eb42e (patch)
tree6fbcb75fd3c2285191939a086989e14656908282 /src/support/file.cpp
parentb013f744e3d70effd9be348cbde7fb93f0a16c6a (diff)
downloadbinaryen-6de14693110b4f898344ff1cb383caf0d74eb42e.tar.gz
binaryen-6de14693110b4f898344ff1cb383caf0d74eb42e.tar.bz2
binaryen-6de14693110b4f898344ff1cb383caf0d74eb42e.zip
wasm-reduce tool (#1139)
Reduce an interesting wasm to a smaller still interesting wasm. This takes an arbitrary command to run, and reduces the wasm as much as it can while keeping the behavior of that command fixed. This can be used to reduce compiler bugs in an arbitrary VM, etc.
Diffstat (limited to 'src/support/file.cpp')
-rw-r--r--src/support/file.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/support/file.cpp b/src/support/file.cpp
index c1d9e6e33..bd6f2d4bd 100644
--- a/src/support/file.cpp
+++ b/src/support/file.cpp
@@ -73,3 +73,15 @@ wasm::Output::Output(const std::string &filename, Flags::BinaryOption binary, Fl
}
return buffer;
}()) {}
+
+void wasm::copy_file(std::string input, std::string output) {
+ std::ifstream src(input, std::ios::binary);
+ std::ofstream dst(output, std::ios::binary);
+ dst << src.rdbuf();
+}
+
+size_t wasm::file_size(std::string filename) {
+ std::ifstream infile(filename, std::ifstream::ate | std::ifstream::binary);
+ return infile.tellg();
+}
+