10 #ifndef SRC_INCLUDE_FILE_H_ 11 #define SRC_INCLUDE_FILE_H_ 20 #include <boost/filesystem.hpp> 49 if (0 != std::fclose(f)) {
50 throw std::runtime_error(std::strerror(errno));
63 using FilePtr = std::unique_ptr<std::FILE, FileDeleter>;
108 FilePtr fopen(
const bf::path& filename,
const std::string& mode);
112 #endif // SRC_INCLUDE_FILE_H_ FilePtr fopen(const bf::path &filename, const std::string &mode)
Open a file with given mode.
FILE * file_
Internal file pointer.
FileDeleter is the deleter class for std::unique_ptr of std::FILE.
bf::path filename_
Path of the finished file.
void operator()(std::FILE *f) const
Frees the std::FILE resource if it is non-zero.
constexpr FileDeleter()=default
The class has no members, so this is a noop.
A RAII type to replace std::FILE *.
bf::path filename_unfinished_
Path of the unfinished file.
std::unique_ptr< std::FILE, FileDeleter > FilePtr
A RAII type to replace std::FILE *.