summaryrefslogtreecommitdiffhomepage
path: root/plugins/webbox/webbox.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-05-11 12:24:04 +0200
committerRoland Reichwein <mail@reichwein.it>2020-05-11 12:24:04 +0200
commit5bc1f7bed536e0e936fd13fad45c49392b0bfff4 (patch)
tree67d4b63e38c6799d63ae4f78168d6838c4e13906 /plugins/webbox/webbox.cpp
parent2715d8e5910304d89a5a1666726aac3b777ad16c (diff)
Separated out routines to libcommon
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"},