summaryrefslogtreecommitdiffhomepage
path: root/plugins/webbox/webbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/webbox/webbox.cpp')
-rw-r--r--plugins/webbox/webbox.cpp35
1 files changed, 4 insertions, 31 deletions
diff --git a/plugins/webbox/webbox.cpp b/plugins/webbox/webbox.cpp
index 7de431a..01241a9 100644
--- a/plugins/webbox/webbox.cpp
+++ b/plugins/webbox/webbox.cpp
@@ -1,9 +1,10 @@
#include "webbox.h"
-#include "file.h"
-#include "stringutil.h"
-
#include "libcommon/mime.h"
+#include "libcommon/tempfile.h"
+#include "libcommon/file.h"
+#include "libcommon/stringutil.h"
+
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -36,34 +37,6 @@ namespace {
static const std::string STATIC_HTML_TARGET{"webbox-html/"};
static const fs::path STATIC_HTML_DOC_ROOT{"/usr/lib/webbox/html"};
- // TODO: separate out
- class Tempfile
- {
- fs::path m_path;
-
- public:
- fs::path GetPath() const
- {
- return m_path;
- }
-
- Tempfile() {
- try {
- m_path = std::string{tmpnam(NULL)} + ".zip"s;
- } catch (const std::exception& ex) {
- throw std::runtime_error("Tempfile error: "s + ex.what());
- }
- }
-
- ~Tempfile() {
- try {
- fs::remove_all(m_path);
- } catch (const std::exception& ex) {
- std::cerr << "Warning: Couldn't remove temporary file " << m_path << std::endl;
- }
- }
- };
-
std::unordered_map<std::string, std::string> status_map {
{ "301", "Moved Permanently" },
{ "400", "Bad Request"},