diff options
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/file.cpp | 12 | ||||
-rw-r--r-- | src/support/file.h | 9 |
2 files changed, 20 insertions, 1 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(); +} + diff --git a/src/support/file.h b/src/support/file.h index 0f0ec15f3..b0df8fd06 100644 --- a/src/support/file.h +++ b/src/support/file.h @@ -66,6 +66,13 @@ class Output { std::ofstream outfile; std::ostream out; }; -} + +// Copies a file to another file +void copy_file(std::string input, std::string output); + +// Retusn the size of a file +size_t file_size(std::string filename); + +} // namespace wasm #endif // wasm_support_file_h |