 |
Version: SMASH-1.8
|
|
Go to the documentation of this file.
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_
std::unique_ptr< std::FILE, FileDeleter > FilePtr
A RAII type to replace std::FILE *.
FilePtr fopen(const bf::path &filename, const std::string &mode)
Open a file with given mode.
~RenamingFilePtr()
Close the file and rename it.
FILE * get()
Get the underlying FILE* pointer.
bf::path filename_unfinished_
Path of the unfinished file.
bf::path filename_
Path of the finished file.
A RAII type to replace std::FILE *.
FILE * file_
Internal file pointer.
void operator()(std::FILE *f) const
Frees the std::FILE resource if it is non-zero.
RenamingFilePtr(const bf::path &filename, const std::string &mode)
Construct a RenamingFilePtr.
constexpr FileDeleter()=default
The class has no members, so this is a noop.
FileDeleter is the deleter class for std::unique_ptr of std::FILE.