add a cmake option to switch between std and boost filesystem

This commit is contained in:
Chunting Gu
2021-05-27 11:15:08 +08:00
parent 39719c4ded
commit df96f969bc
31 changed files with 227 additions and 195 deletions
+4 -7
View File
@@ -3,14 +3,11 @@
#include <iostream>
#include "boost/algorithm/string.hpp"
#include "boost/filesystem/operations.hpp"
#include "json/json.h"
#include "book_json.h"
namespace bfs = boost::filesystem;
BookClient::BookClient(const std::string& url, int timeout)
: url_(url), session_(timeout) {
// Default Content-Type for requests with a body.
@@ -127,7 +124,7 @@ bool BookClient::Delete(const std::string& id) {
}
}
bool BookClient::GetPhoto(const std::string& id, const bfs::path& path) {
bool BookClient::GetPhoto(const std::string& id, const webcc::fs::path& path) {
try {
auto r = session_.Send(WEBCC_GET(url_).
Path("books").Path(id).Path("photo")(),
@@ -147,7 +144,7 @@ bool BookClient::GetPhoto(const std::string& id, const bfs::path& path) {
}
}
bool BookClient::SetPhoto(const std::string& id, const bfs::path& path) {
bool BookClient::SetPhoto(const std::string& id, const webcc::fs::path& path) {
try {
if (!CheckPhoto(path)) {
return false;
@@ -169,12 +166,12 @@ bool BookClient::SetPhoto(const std::string& id, const bfs::path& path) {
}
}
bool BookClient::CheckPhoto(const bfs::path& photo) {
bool BookClient::CheckPhoto(const webcc::fs::path& photo) {
if (photo.empty()) {
return false;
}
if (!bfs::is_regular_file(photo) || !bfs::exists(photo)) {
if (!webcc::fs::is_regular_file(photo) || !webcc::fs::exists(photo)) {
return false;
}