From 5bc1f7bed536e0e936fd13fad45c49392b0bfff4 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 11 May 2020 12:24:04 +0200 Subject: Separated out routines to libcommon --- plugins/webbox/webbox.cpp | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'plugins/webbox/webbox.cpp') 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 #include @@ -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 status_map { { "301", "Moved Permanently" }, { "400", "Bad Request"}, -- cgit v1.2.3