switch back to boost::filesystem to avoid the requirement of c++17

This commit is contained in:
Chunting Gu
2020-09-07 19:01:31 +08:00
parent e7f88da2b2
commit 84476f75f7
31 changed files with 175 additions and 192 deletions
+7 -5
View File
@@ -4,20 +4,22 @@
#include <fstream>
#include <utility>
#include "boost/filesystem/operations.hpp"
#include "webcc/body.h"
#include "webcc/logger.h"
#include "webcc/request.h"
#include "webcc/response.h"
#include "webcc/utility.h"
namespace sfs = std::filesystem;
namespace bfs = boost::filesystem;
using tcp = boost::asio::ip::tcp;
namespace webcc {
Server::Server(boost::asio::ip::tcp protocol, std::uint16_t port,
const sfs::path& doc_root)
const bfs::path& doc_root)
: protocol_(protocol),
port_(port),
doc_root_(doc_root),
@@ -302,8 +304,8 @@ bool Server::MatchViewOrStatic(const std::string& method,
// Try to match a static file.
if (method == methods::kGet && !doc_root_.empty()) {
sfs::path path = doc_root_ / url;
if (!sfs::is_directory(path) && sfs::exists(path)) {
bfs::path path = doc_root_ / url;
if (!bfs::is_directory(path) && bfs::exists(path)) {
return true;
}
}
@@ -319,7 +321,7 @@ ResponsePtr Server::ServeStatic(RequestPtr request) {
return {};
}
sfs::path path = doc_root_ / request->url().path();
bfs::path path = doc_root_ / request->url().path();
try {
// NOTE: FileBody might throw Error::kFileError.