diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-10-04 16:56:02 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-10-04 16:56:02 +0200 |
commit | f0f4b8a4d139a855ad15f9d79190edf6320eba51 (patch) | |
tree | 4ba361738f08bf44769e3454832d765ba8d7f2c1 /src/Filesystem.hpp | |
parent | 5ff3d7a51be30a0052b12f9330fdf54f3c104739 (diff) |
Static file cache content module.
* remove EVHTTP headers
* magic/mime type support for virtual Filesystem
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/Filesystem.hpp')
-rw-r--r-- | src/Filesystem.hpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Filesystem.hpp b/src/Filesystem.hpp index 13733c9..02150fb 100644 --- a/src/Filesystem.hpp +++ b/src/Filesystem.hpp @@ -1,13 +1,18 @@ #ifndef FILESYSTEM_H #define FILESYSTEM_H 1 +#include <magic.h> + #include <inja/inja.hpp> #include <string> #include <unordered_map> #include <vector> +using FilesDict = std::unordered_map<std::string, struct file_data>; + struct file_data { + std::string mime; std::vector<unsigned char> data; }; @@ -16,18 +21,24 @@ class Filesystem public: Filesystem() { + MagicInit(); } ~Filesystem() { + MagicClose(); } - bool AddSingleFile(std::string path, std::string root); bool Scan(std::string root = "./wwwroot"); bool Scan(std::string root, std::vector<std::string> extensions, bool exclude_extensions = false); - const std::unordered_map<std::string, struct file_data> & GetFiles() const; + FilesDict & GetFiles(); private: - std::unordered_map<std::string, struct file_data> m_Files; + bool AddSingleFile(std::string path, std::string root); + void MagicInit(); + void MagicClose(); + + FilesDict m_Files; + magic_t m_Magic; }; #endif |