summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llmr/util/io.hpp14
-rw-r--r--src/util/io.cpp13
2 files changed, 27 insertions, 0 deletions
diff --git a/include/llmr/util/io.hpp b/include/llmr/util/io.hpp
new file mode 100644
index 0000000000..f1e560ffe4
--- /dev/null
+++ b/include/llmr/util/io.hpp
@@ -0,0 +1,14 @@
+#ifndef LLMR_UTIL_IO
+#define LLMR_UTIL_IO
+
+#include <string>
+
+namespace llmr {
+namespace util {
+
+void write_file(const std::string &filename, const std::string &data);
+
+}
+}
+
+#endif
diff --git a/src/util/io.cpp b/src/util/io.cpp
new file mode 100644
index 0000000000..bf519b0573
--- /dev/null
+++ b/src/util/io.cpp
@@ -0,0 +1,13 @@
+#include <llmr/util/io.hpp>
+
+#include <cstdio>
+
+void llmr::util::write_file(const std::string &filename, const std::string &data) {
+ FILE *fd = fopen(filename.c_str(), "wb");
+ if (fd) {
+ fwrite(data.data(), sizeof(std::string::value_type), data.size(), fd);
+ fclose(fd);
+ } else {
+ fprintf(stderr, "Failed to open file\n");
+ }
+}