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
+8 -5
View File
@@ -2,15 +2,18 @@
#include <algorithm>
#include <ctime>
#include <filesystem>
#include <fstream>
#include <iomanip> // for put_time
#include <iostream>
#include <sstream>
#include "boost/filesystem/fstream.hpp"
#include "webcc/string.h"
#include "webcc/version.h"
namespace bfs = boost::filesystem;
namespace webcc {
namespace utility {
@@ -49,18 +52,18 @@ std::string HttpDate() {
return std::string(buf) + " GMT";
}
std::size_t TellSize(const std::filesystem::path& path) {
std::size_t TellSize(const bfs::path& path) {
// Flag "ate": seek to the end of stream immediately after open.
std::ifstream stream{ path, std::ios::binary | std::ios::ate };
bfs::ifstream stream{ path, std::ios::binary | std::ios::ate };
if (stream.fail()) {
return kInvalidLength;
}
return static_cast<std::size_t>(stream.tellg());
}
bool ReadFile(const std::filesystem::path& path, std::string* output) {
bool ReadFile(const bfs::path& path, std::string* output) {
// Flag "ate": seek to the end of stream immediately after open.
std::ifstream stream{ path, std::ios::binary | std::ios::ate };
bfs::ifstream stream{ path, std::ios::binary | std::ios::ate };
if (stream.fail()) {
return false;
}