replace boost filesystem with std filesystem; upgrade gtest and find it using cmake.

This commit is contained in:
Chunting Gu
2020-02-15 12:04:51 +08:00
parent 7e3da65e73
commit 7e7ab1c1e8
72 changed files with 233 additions and 31551 deletions
+9 -17
View File
@@ -1,8 +1,6 @@
#include "webcc/body.h"
#include "boost/algorithm/string.hpp"
#include "boost/core/ignore_unused.hpp"
#include "boost/filesystem/operations.hpp"
#include "webcc/logger.h"
#include "webcc/utility.h"
@@ -11,8 +9,6 @@
#include "webcc/gzip.h"
#endif
namespace bfs = boost::filesystem;
namespace webcc {
// -----------------------------------------------------------------------------
@@ -61,9 +57,7 @@ void StringBody::InitPayload() {
index_ = 0;
}
Payload StringBody::NextPayload(bool free_previous) {
boost::ignore_unused(free_previous);
Payload StringBody::NextPayload(bool /*free_previous*/) {
if (index_ == 0) {
index_ = 1;
return { boost::asio::buffer(data_) };
@@ -161,7 +155,7 @@ void FormBody::Free(std::size_t index) {
// -----------------------------------------------------------------------------
FileBody::FileBody(const Path& path, std::size_t chunk_size)
FileBody::FileBody(const std::filesystem::path& path, std::size_t chunk_size)
: path_(path), chunk_size_(chunk_size), auto_delete_(false), size_(0) {
size_ = utility::TellSize(path_);
if (size_ == kInvalidLength) {
@@ -169,15 +163,15 @@ FileBody::FileBody(const Path& path, std::size_t chunk_size)
}
}
FileBody::FileBody(const Path& path, bool auto_delete)
FileBody::FileBody(const std::filesystem::path& path, bool auto_delete)
: path_(path), chunk_size_(0), auto_delete_(auto_delete), size_(0) {
// Don't need to tell file size.
}
FileBody::~FileBody() {
if (auto_delete_ && !path_.empty()) {
boost::system::error_code ec;
bfs::remove(path_, ec);
std::error_code ec;
std::filesystem::remove(path_, ec);
if (ec) {
LOG_ERRO("Failed to remove file (%s).", ec.message().c_str());
}
@@ -200,9 +194,7 @@ void FileBody::InitPayload() {
}
}
Payload FileBody::NextPayload(bool free_previous) {
boost::ignore_unused(free_previous);
Payload FileBody::NextPayload(bool /*free_previous*/) {
if (ifstream_.read(&chunk_[0], chunk_.size()).gcount() > 0) {
return {
boost::asio::buffer(chunk_.data(), (std::size_t)ifstream_.gcount())
@@ -215,7 +207,7 @@ void FileBody::Dump(std::ostream& os, const std::string& prefix) const {
os << prefix << "<file: " << path_.string() << ">" << std::endl;
}
bool FileBody::Move(const Path& new_path) {
bool FileBody::Move(const std::filesystem::path& new_path) {
if (path_ == new_path) {
return false;
}
@@ -224,8 +216,8 @@ bool FileBody::Move(const Path& new_path) {
ifstream_.close();
}
boost::system::error_code ec;
bfs::rename(path_, new_path, ec);
std::error_code ec;
std::filesystem::rename(path_, new_path, ec);
if (ec) {
LOG_ERRO("Failed to rename file (%s).", ec.message().c_str());