34 #include <BESInternalError.h> 36 #include "BESHandlerUtil.h" 48 TemporaryFile::~TemporaryFile()
52 ERROR(
string(
"Error closing temporary file: ").append(&d_name[0]).append(
": ").append(strerror(errno)));
53 if (!unlink(&d_name[0]))
54 ERROR(
string(
"Error closing temporary file: ").append(&d_name[0]).append(
": ").append(strerror(errno)));
74 TemporaryFile::TemporaryFile(
const std::string &path_template)
78 d_name.reserve(path_template.length() + 1);
80 string::size_type len = path_template.copy(&d_name[0], path_template.length());
85 mode_t original_mode = umask(077);
86 d_fd = mkstemp(&d_name[0]);
89 if (d_fd == -1)
throw BESInternalError(
"Failed to open the temporary file.", __FILE__, __LINE__);
exception thrown if inernal error encountered