]> git.sesse.net Git - cubemap/blobdiff - util.h
Move the “read the whole file” logic into a new file.
[cubemap] / util.h
diff --git a/util.h b/util.h
new file mode 100644 (file)
index 0000000..f64e257
--- /dev/null
+++ b/util.h
@@ -0,0 +1,15 @@
+#ifndef _UTIL_H
+#define _UTIL_H
+
+// Some utilities for reading and writing to temporary files.
+
+#include <string>
+
+// Make a file in /tmp, unlink it, and write <contents> to it.
+// Returns the opened file descriptor, or -1 on failure.
+int make_tempfile(const std::string &contents);
+
+// Opposite of make_tempfile(). Returns false on failure.
+bool read_tempfile(int fd, std::string *contents);
+
+#endif  // !defined(_UTIL_H