add a cmake option to switch between std and boost filesystem
This commit is contained in:
+7
-11
@@ -1,7 +1,5 @@
|
||||
#include "webcc/body.h"
|
||||
|
||||
#include "boost/filesystem/operations.hpp"
|
||||
|
||||
#include "webcc/logger.h"
|
||||
#include "webcc/utility.h"
|
||||
|
||||
@@ -9,8 +7,6 @@
|
||||
#include "webcc/gzip.h"
|
||||
#endif
|
||||
|
||||
namespace bfs = boost::filesystem;
|
||||
|
||||
namespace webcc {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -157,7 +153,7 @@ void FormBody::Free(std::size_t index) {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
FileBody::FileBody(const bfs::path& path, std::size_t chunk_size)
|
||||
FileBody::FileBody(const fs::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) {
|
||||
@@ -165,15 +161,15 @@ FileBody::FileBody(const bfs::path& path, std::size_t chunk_size)
|
||||
}
|
||||
}
|
||||
|
||||
FileBody::FileBody(const bfs::path& path, bool auto_delete)
|
||||
FileBody::FileBody(const fs::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);
|
||||
fs::error_code ec;
|
||||
fs::remove(path_, ec);
|
||||
if (ec) {
|
||||
LOG_ERRO("Failed to remove file (%s).", ec.message().c_str());
|
||||
}
|
||||
@@ -209,7 +205,7 @@ void FileBody::Dump(std::ostream& os, const std::string& prefix) const {
|
||||
os << prefix << "<file: " << path_.string() << ">" << std::endl;
|
||||
}
|
||||
|
||||
bool FileBody::Move(const bfs::path& new_path) {
|
||||
bool FileBody::Move(const fs::path& new_path) {
|
||||
if (path_ == new_path) {
|
||||
return false;
|
||||
}
|
||||
@@ -218,8 +214,8 @@ bool FileBody::Move(const bfs::path& new_path) {
|
||||
ifstream_.close();
|
||||
}
|
||||
|
||||
boost::system::error_code ec;
|
||||
bfs::rename(path_, new_path, ec);
|
||||
fs::error_code ec;
|
||||
fs::rename(path_, new_path, ec);
|
||||
|
||||
if (ec) {
|
||||
LOG_ERRO("Failed to rename file (%s).", ec.message().c_str());
|
||||
|
||||
Reference in New Issue
Block a user