4 // Some utilities for reading and writing to temporary files.
8 // Make a file in /tmp, unlink it, and write <contents> to it.
9 // Returns the opened file descriptor, or -1 on failure.
10 int make_tempfile(const std::string &contents);
12 // Opposite of make_tempfile(). Returns false on failure.
13 bool read_tempfile_and_close(int fd, std::string *contents);
15 // Same as read_tempfile_and_close(), without the close.
16 bool read_tempfile(int fd, std::string *contents);
18 // Close a file descriptor, taking care of EINTR on the way.
19 // log_perror() if it fails; apart from that, behaves as close().
20 int safe_close(int fd);
22 #endif // !defined(_UTIL_H