Replace boost::filesystem with std::filesystem
This allows us to use a header-only copy of Boost
This commit is contained in:
parent
74822c4a84
commit
8a94fb7db0
|
@ -65,7 +65,7 @@ set(Boost_USE_STATIC_LIBS ON) # Use static libs
|
|||
set(Boost_USE_MULTITHREADED ON) # Enable multithreading support
|
||||
set(Boost_USE_STATIC_RUNTIME ON) # Use static C++ runtime
|
||||
set(Boost_NO_BOOST_CMAKE ON) # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/18865
|
||||
find_package(Boost 1.54 REQUIRED COMPONENTS filesystem locale system)
|
||||
find_package(Boost 1.54 REQUIRED)
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||
link_libraries(${Boost_LIBRARIES}) # Just about every project needs Boost
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <format.h>
|
||||
#include "tools/fileTools.h"
|
||||
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::vector;
|
||||
using std::make_shared;
|
||||
using std::ifstream;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "AudioClip.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
class OggVorbisFileReader : public AudioClip {
|
||||
public:
|
||||
OggVorbisFileReader(const boost::filesystem::path& filePath);
|
||||
OggVorbisFileReader(const std::filesystem::path& filePath);
|
||||
std::unique_ptr<AudioClip> clone() const override;
|
||||
int getSampleRate() const override { return sampleRate; }
|
||||
size_type size() const override { return sampleCount; }
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
private:
|
||||
SampleReader createUnsafeSampleReader() const override;
|
||||
|
||||
boost::filesystem::path filePath;
|
||||
std::filesystem::path filePath;
|
||||
int sampleRate;
|
||||
int channelCount;
|
||||
size_type sampleCount;
|
||||
|
|
|
@ -12,7 +12,7 @@ using namespace little_endian;
|
|||
using std::unique_ptr;
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
|
||||
#define INT24_MIN (-8388608)
|
||||
#define INT24_MAX 8388607
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
#include "AudioClip.h"
|
||||
|
||||
enum class SampleFormat {
|
||||
|
@ -12,7 +12,7 @@ enum class SampleFormat {
|
|||
|
||||
class WaveFileReader : public AudioClip {
|
||||
public:
|
||||
WaveFileReader(const boost::filesystem::path& filePath);
|
||||
WaveFileReader(const std::filesystem::path& filePath);
|
||||
std::unique_ptr<AudioClip> clone() const override;
|
||||
int getSampleRate() const override;
|
||||
size_type size() const override;
|
||||
|
@ -29,7 +29,7 @@ private:
|
|||
std::streampos dataOffset;
|
||||
};
|
||||
|
||||
boost::filesystem::path filePath;
|
||||
std::filesystem::path filePath;
|
||||
WaveFormatInfo formatInfo;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include "OggVorbisFileReader.h"
|
||||
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::string;
|
||||
using std::runtime_error;
|
||||
using fmt::format;
|
||||
|
@ -12,7 +12,7 @@ using fmt::format;
|
|||
std::unique_ptr<AudioClip> createAudioFileClip(path filePath) {
|
||||
try {
|
||||
const string extension =
|
||||
boost::algorithm::to_lower_copy(boost::filesystem::extension(filePath));
|
||||
boost::algorithm::to_lower_copy(filePath.extension().u8string());
|
||||
if (extension == ".wav") {
|
||||
return std::make_unique<WaveFileReader>(filePath);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ std::unique_ptr<AudioClip> createAudioFileClip(path filePath) {
|
|||
extension
|
||||
));
|
||||
} catch (...) {
|
||||
std::throw_with_nested(runtime_error(format("Could not open sound file {}.", filePath)));
|
||||
std::throw_with_nested(runtime_error(format("Could not open sound file {}.", filePath.u8string())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
#include <memory>
|
||||
#include "AudioClip.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::unique_ptr<AudioClip> createAudioFileClip(boost::filesystem::path filePath);
|
||||
std::unique_ptr<AudioClip> createAudioFileClip(std::filesystem::path filePath);
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
#include "core/Shape.h"
|
||||
#include "time/ContinuousTimeline.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
class ExporterInput {
|
||||
public:
|
||||
ExporterInput(
|
||||
const boost::filesystem::path& inputFilePath,
|
||||
const std::filesystem::path& inputFilePath,
|
||||
const JoiningContinuousTimeline<Shape>& animation,
|
||||
const ShapeSet& targetShapeSet) :
|
||||
inputFilePath(inputFilePath),
|
||||
animation(animation),
|
||||
targetShapeSet(targetShapeSet) {}
|
||||
|
||||
boost::filesystem::path inputFilePath;
|
||||
std::filesystem::path inputFilePath;
|
||||
JoiningContinuousTimeline<Shape> animation;
|
||||
ShapeSet targetShapeSet;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "JsonExporter.h"
|
||||
#include "exporterTools.h"
|
||||
#include "tools/stringTools.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@ -11,7 +10,7 @@ void JsonExporter::exportAnimation(const ExporterInput& input, std::ostream& out
|
|||
// the formatting.
|
||||
outputStream << "{\n";
|
||||
outputStream << " \"metadata\": {\n";
|
||||
outputStream << " \"soundFile\": \"" << escapeJsonString(absolute(input.inputFilePath).string()) << "\",\n";
|
||||
outputStream << " \"soundFile\": \"" << escapeJsonString(absolute(input.inputFilePath).u8string()) << "\",\n";
|
||||
outputStream << " \"duration\": " << formatDuration(input.animation.getRange().getDuration()) << "\n";
|
||||
outputStream << " },\n";
|
||||
outputStream << " \"mouthCues\": [\n";
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <boost/property_tree/xml_parser.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include "exporterTools.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using std::string;
|
||||
using boost::property_tree::ptree;
|
||||
|
@ -12,7 +11,7 @@ void XmlExporter::exportAnimation(const ExporterInput& input, std::ostream& outp
|
|||
ptree tree;
|
||||
|
||||
// Add metadata
|
||||
tree.put("rhubarbResult.metadata.soundFile", absolute(input.inputFilePath).string());
|
||||
tree.put("rhubarbResult.metadata.soundFile", absolute(input.inputFilePath).u8string());
|
||||
tree.put(
|
||||
"rhubarbResult.metadata.duration",
|
||||
formatDuration(input.animation.getRange().getDuration())
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
using boost::optional;
|
||||
using std::string;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
|
||||
JoiningContinuousTimeline<Shape> animateAudioClip(
|
||||
const AudioClip& audioClip,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "time/ContinuousTimeline.h"
|
||||
#include "audio/AudioClip.h"
|
||||
#include "tools/progress.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
#include "animation/targetShapeSet.h"
|
||||
#include "recognition/Recognizer.h"
|
||||
|
||||
|
@ -17,7 +17,7 @@ JoiningContinuousTimeline<Shape> animateAudioClip(
|
|||
ProgressSink& progressSink);
|
||||
|
||||
JoiningContinuousTimeline<Shape> animateWaveFile(
|
||||
boost::filesystem::path filePath,
|
||||
std::filesystem::path filePath,
|
||||
const boost::optional<std::string>& dialog,
|
||||
const Recognizer& recognizer,
|
||||
const ShapeSet& targetShapeSet,
|
||||
|
|
|
@ -17,9 +17,9 @@ static lambda_unique_ptr<ps_decoder_t> createDecoder(optional<std::string> dialo
|
|||
cmd_ln_init(
|
||||
nullptr, ps_args(), true,
|
||||
// Set acoustic model
|
||||
"-hmm", (getSphinxModelDirectory() / "acoustic-model").string().c_str(),
|
||||
"-hmm", (getSphinxModelDirectory() / "acoustic-model").u8string().c_str(),
|
||||
// Set phonetic language model
|
||||
"-allphone", (getSphinxModelDirectory() / "en-us-phone.lm.bin").string().c_str(),
|
||||
"-allphone", (getSphinxModelDirectory() / "en-us-phone.lm.bin").u8string().c_str(),
|
||||
"-allphone_ci", "yes",
|
||||
// Set language model probability weight.
|
||||
// Low values (<= 0.4) can lead to fluttering animation.
|
||||
|
|
|
@ -20,7 +20,7 @@ using std::unique_ptr;
|
|||
using std::string;
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::regex;
|
||||
using std::regex_replace;
|
||||
using boost::optional;
|
||||
|
@ -58,10 +58,10 @@ void addMissingDictionaryWords(const vector<string>& words, ps_decoder_t& decode
|
|||
lambda_unique_ptr<ngram_model_t> createDefaultLanguageModel(ps_decoder_t& decoder) {
|
||||
path modelPath = getSphinxModelDirectory() / "en-us.lm.bin";
|
||||
lambda_unique_ptr<ngram_model_t> result(
|
||||
ngram_model_read(decoder.config, modelPath.string().c_str(), NGRAM_AUTO, decoder.lmath),
|
||||
ngram_model_read(decoder.config, modelPath.u8string().c_str(), NGRAM_AUTO, decoder.lmath),
|
||||
[](ngram_model_t* lm) { ngram_model_free(lm); });
|
||||
if (!result) {
|
||||
throw runtime_error(fmt::format("Error reading language model from {}.", modelPath));
|
||||
throw runtime_error(fmt::format("Error reading language model from {}.", modelPath.u8string()));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -120,9 +120,9 @@ static lambda_unique_ptr<ps_decoder_t> createDecoder(optional<std::string> dialo
|
|||
cmd_ln_init(
|
||||
nullptr, ps_args(), true,
|
||||
// Set acoustic model
|
||||
"-hmm", (getSphinxModelDirectory() / "acoustic-model").string().c_str(),
|
||||
"-hmm", (getSphinxModelDirectory() / "acoustic-model").u8string().c_str(),
|
||||
// Set pronunciation dictionary
|
||||
"-dict", (getSphinxModelDirectory() / "cmudict-en-us.dict").string().c_str(),
|
||||
"-dict", (getSphinxModelDirectory() / "cmudict-en-us.dict").u8string().c_str(),
|
||||
// Add noise against zero silence
|
||||
// (see http://cmusphinx.sourceforge.net/wiki/faq#qwhy_my_accuracy_is_poor)
|
||||
"-dither", "yes",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <map>
|
||||
#include <tuple>
|
||||
#include "tools/platformTools.h"
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <fstream>
|
||||
#include "core/appInfo.h"
|
||||
#include <cmath>
|
||||
#include <gsl_util.h>
|
||||
|
@ -17,7 +17,7 @@ using std::map;
|
|||
using std::tuple;
|
||||
using std::get;
|
||||
using std::endl;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
|
||||
using Unigram = string;
|
||||
using Bigram = tuple<string, string>;
|
||||
|
@ -151,7 +151,7 @@ void createLanguageModelFile(const vector<string>& words, const path& filePath)
|
|||
map<Bigram, double> bigramBackoffWeights =
|
||||
getBigramBackoffWeights(bigramCounts, bigramProbabilities, trigramCounts, discountMass);
|
||||
|
||||
boost::filesystem::ofstream file(filePath);
|
||||
std::ofstream file(filePath);
|
||||
file << "Generated by " << appName << " " << appVersion << endl << endl;
|
||||
|
||||
file << "\\data\\" << endl;
|
||||
|
@ -193,9 +193,9 @@ lambda_unique_ptr<ngram_model_t> createLanguageModel(
|
|||
) {
|
||||
path tempFilePath = getTempFilePath();
|
||||
createLanguageModelFile(words, tempFilePath);
|
||||
auto deleteTempFile = gsl::finally([&]() { boost::filesystem::remove(tempFilePath); });
|
||||
auto deleteTempFile = gsl::finally([&]() { std::filesystem::remove(tempFilePath); });
|
||||
|
||||
return lambda_unique_ptr<ngram_model_t>(
|
||||
ngram_model_read(decoder.config, tempFilePath.string().c_str(), NGRAM_ARPA, decoder.lmath),
|
||||
ngram_model_read(decoder.config, tempFilePath.u8string().c_str(), NGRAM_ARPA, decoder.lmath),
|
||||
[](ngram_model_t* lm) { ngram_model_free(lm); });
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ using std::invalid_argument;
|
|||
using std::unique_ptr;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::regex;
|
||||
using boost::optional;
|
||||
using std::chrono::duration_cast;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "core/Phone.h"
|
||||
#include "audio/AudioClip.h"
|
||||
#include "tools/progress.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
extern "C" {
|
||||
#include <pocketsphinx.h>
|
||||
|
@ -32,7 +32,7 @@ BoundedTimeline<Phone> recognizePhones(
|
|||
|
||||
constexpr int sphinxSampleRate = 16000;
|
||||
|
||||
const boost::filesystem::path& getSphinxModelDirectory();
|
||||
const std::filesystem::path& getSphinxModelDirectory();
|
||||
|
||||
JoiningTimeline<void> getNoiseSounds(TimeRange utteranceTimeRange, const Timeline<Phone>& phones);
|
||||
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
#include <gsl_util.h>
|
||||
#include "exporters/Exporter.h"
|
||||
#include "time/ContinuousTimeline.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include "tools/stringTools.h"
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <fstream>
|
||||
#include "tools/parallel.h"
|
||||
#include "tools/exceptions.h"
|
||||
#include "tools/textFiles.h"
|
||||
|
@ -39,7 +38,8 @@ using std::unique_ptr;
|
|||
using std::make_unique;
|
||||
using std::shared_ptr;
|
||||
using std::make_shared;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::filesystem::u8path;
|
||||
using boost::adaptors::transformed;
|
||||
using boost::optional;
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace TCLAP {
|
|||
}
|
||||
|
||||
shared_ptr<logging::Sink> createFileSink(const path& path, logging::Level minLevel) {
|
||||
auto file = make_shared<boost::filesystem::ofstream>();
|
||||
auto file = make_shared<std::ofstream>();
|
||||
file->exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
file->open(path);
|
||||
auto FileSink =
|
||||
|
@ -121,9 +121,8 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
shared_ptr<logging::Sink> defaultSink = make_shared<NiceStderrSink>(defaultMinStderrLevel);
|
||||
logging::addSink(defaultSink);
|
||||
|
||||
// Use UTF-8 throughout
|
||||
// Make sure the console uses UTF-8 on all platforms including Windows
|
||||
useUtf8ForConsole();
|
||||
useUtf8ForBoostFilesystem();
|
||||
|
||||
// Convert command-line arguments to UTF-8
|
||||
const vector<string> args = argsToUtf8(platformArgc, platformArgv);
|
||||
|
@ -229,7 +228,7 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
logging::removeSink(defaultSink);
|
||||
// ... to log file
|
||||
if (logFileName.isSet()) {
|
||||
auto fileSink = createFileSink(path(logFileName.getValue()), logLevel.getValue());
|
||||
auto fileSink = createFileSink(u8path(logFileName.getValue()), logLevel.getValue());
|
||||
logging::addSink(fileSink);
|
||||
}
|
||||
|
||||
|
@ -237,7 +236,7 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
if (maxThreadCount.getValue() < 1) {
|
||||
throw std::runtime_error("Thread count must be 1 or higher.");
|
||||
}
|
||||
path inputFilePath(inputFileName.getValue());
|
||||
path inputFilePath = u8path(inputFileName.getValue());
|
||||
ShapeSet targetShapeSet = getTargetShapeSet(extendedShapes.getValue());
|
||||
|
||||
unique_ptr<Exporter> exporter = createExporter(
|
||||
|
@ -262,7 +261,7 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
JoiningContinuousTimeline<Shape> animation = animateWaveFile(
|
||||
inputFilePath,
|
||||
dialogFile.isSet()
|
||||
? readUtf8File(path(dialogFile.getValue()))
|
||||
? readUtf8File(u8path(dialogFile.getValue()))
|
||||
: boost::optional<string>(),
|
||||
*createRecognizer(recognizerType.getValue()),
|
||||
targetShapeSet,
|
||||
|
@ -271,9 +270,9 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
logging::info("Done animating.");
|
||||
|
||||
// Export animation
|
||||
optional<boost::filesystem::ofstream> outputFile;
|
||||
optional<std::ofstream> outputFile;
|
||||
if (outputFileName.isSet()) {
|
||||
outputFile = boost::in_place(outputFileName.getValue());
|
||||
outputFile = boost::in_place(u8path(outputFileName.getValue()));
|
||||
outputFile->exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
}
|
||||
ExporterInput exporterInput = ExporterInput(inputFilePath, animation, targetShapeSet);
|
||||
|
@ -284,7 +283,7 @@ int main(int platformArgc, char* platformArgv[]) {
|
|||
logging::log(SuccessEntry());
|
||||
} catch (...) {
|
||||
std::throw_with_nested(
|
||||
std::runtime_error(fmt::format("Error processing file {}.", inputFilePath))
|
||||
std::runtime_error(fmt::format("Error processing file {}.", inputFilePath.u8string()))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ SemanticEntry::SemanticEntry(Level level, const string& message) :
|
|||
Entry(level, message)
|
||||
{}
|
||||
|
||||
StartEntry::StartEntry(const boost::filesystem::path& inputFilePath) :
|
||||
SemanticEntry(Level::Info, fmt::format("Application startup. Input file: {}.", inputFilePath)),
|
||||
StartEntry::StartEntry(const std::filesystem::path& inputFilePath) :
|
||||
SemanticEntry(Level::Info, fmt::format("Application startup. Input file: {}.", inputFilePath.u8string())),
|
||||
inputFilePath(inputFilePath)
|
||||
{}
|
||||
|
||||
boost::filesystem::path StartEntry::getInputFilePath() const {
|
||||
std::filesystem::path StartEntry::getInputFilePath() const {
|
||||
return inputFilePath;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "logging/Entry.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
// Marker class for semantic entries
|
||||
class SemanticEntry : public logging::Entry {
|
||||
|
@ -10,10 +10,10 @@ public:
|
|||
|
||||
class StartEntry : public SemanticEntry {
|
||||
public:
|
||||
StartEntry(const boost::filesystem::path& inputFilePath);
|
||||
boost::filesystem::path getInputFilePath() const;
|
||||
StartEntry(const std::filesystem::path& inputFilePath);
|
||||
std::filesystem::path getInputFilePath() const;
|
||||
private:
|
||||
boost::filesystem::path inputFilePath;
|
||||
std::filesystem::path inputFilePath;
|
||||
};
|
||||
|
||||
class ProgressEntry : public SemanticEntry {
|
||||
|
|
|
@ -24,7 +24,7 @@ void NiceStderrSink::receive(const logging::Entry& entry) {
|
|||
// the technical log message.
|
||||
if (const auto* startEntry = dynamic_cast<const StartEntry*>(&entry)) {
|
||||
std::cerr
|
||||
<< fmt::format("Generating lip sync data for {}.", startEntry->getInputFilePath())
|
||||
<< fmt::format("Generating lip sync data for {}.", startEntry->getInputFilePath().u8string())
|
||||
<< std::endl;
|
||||
startProgressIndication();
|
||||
} else if (const auto* progressEntry = dynamic_cast<const ProgressEntry*>(&entry)) {
|
||||
|
@ -75,7 +75,7 @@ void QuietStderrSink::receive(const logging::Entry& entry) {
|
|||
if (quietSoFar) {
|
||||
// This is the first message we print. Give a bit of context.
|
||||
const string intro = inputFilePath
|
||||
? fmt::format("{} {} processing file {}:", appName, appVersion, *inputFilePath)
|
||||
? fmt::format("{} {} processing file {}:", appName, appVersion, inputFilePath->u8string())
|
||||
: fmt::format("{} {}:", appName, appVersion);
|
||||
std::cerr << intro << std::endl;
|
||||
quietSoFar = false;
|
||||
|
@ -100,7 +100,7 @@ void MachineReadableStderrSink::receive(const logging::Entry& entry) {
|
|||
optional<string> line;
|
||||
if (dynamic_cast<const SemanticEntry*>(&entry)) {
|
||||
if (const auto* startEntry = dynamic_cast<const StartEntry*>(&entry)) {
|
||||
const string file = escapeJsonString(startEntry->getInputFilePath().string());
|
||||
const string file = escapeJsonString(startEntry->getInputFilePath().u8string());
|
||||
line = fmt::format(
|
||||
R"({{ "type": "start", "file": "{}", {} }})",
|
||||
file,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "logging/Entry.h"
|
||||
#include "logging/Sink.h"
|
||||
#include "tools/ProgressBar.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
// Prints nicely formatted progress to stderr.
|
||||
// Non-semantic entries are only printed if their log level at least matches the specified minimum level.
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
private:
|
||||
logging::Level minLevel;
|
||||
bool quietSoFar = true;
|
||||
boost::optional<boost::filesystem::path> inputFilePath;
|
||||
boost::optional<std::filesystem::path> inputFilePath;
|
||||
std::shared_ptr<Sink> innerSink;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ using std::cout;
|
|||
using std::endl;
|
||||
|
||||
string getBinaryName() {
|
||||
return getBinPath().filename().string();
|
||||
return getBinPath().filename().u8string();
|
||||
}
|
||||
|
||||
void NiceCmdLineOutput::version(CmdLineInterface& cli) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <cerrno>
|
||||
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
|
||||
std::ifstream openFile(path filePath) {
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
#include "platformTools.h"
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
std::ifstream openFile(boost::filesystem::path filePath);
|
||||
std::ifstream openFile(std::filesystem::path filePath);
|
||||
|
||||
void throwIfNotReadable(boost::filesystem::path filePath);
|
||||
void throwIfNotReadable(std::filesystem::path filePath);
|
|
@ -1,5 +1,4 @@
|
|||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
#include <format.h>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
|
@ -9,14 +8,14 @@
|
|||
#include <utf8.h>
|
||||
#include <gsl_util.h>
|
||||
#include "tools.h"
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#include <codecvt>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
@ -39,9 +38,9 @@ path getBinPath() {
|
|||
}
|
||||
buffer[pathLength] = 0;
|
||||
|
||||
// Convert to boost::filesystem::path
|
||||
// Convert to std::filesystem::path
|
||||
const string pathString(buffer.data());
|
||||
path result(boost::filesystem::canonical(pathString).make_preferred());
|
||||
path result(std::filesystem::canonical(pathString).make_preferred());
|
||||
return result;
|
||||
} catch (...) {
|
||||
std::throw_with_nested(std::runtime_error("Could not determine path of bin directory."));
|
||||
|
@ -55,7 +54,7 @@ path getBinDirectory() {
|
|||
}
|
||||
|
||||
path getTempFilePath() {
|
||||
const path tempDirectory = boost::filesystem::temp_directory_path();
|
||||
const path tempDirectory = std::filesystem::temp_directory_path();
|
||||
static boost::uuids::random_generator generateUuid;
|
||||
const string fileName = to_string(generateUuid());
|
||||
return tempDirectory / fileName;
|
||||
|
@ -145,9 +144,3 @@ void useUtf8ForConsole() {
|
|||
std::cerr.rdbuf(new ConsoleBuffer(stderr));
|
||||
#endif
|
||||
}
|
||||
|
||||
void useUtf8ForBoostFilesystem() {
|
||||
const std::locale globalLocale = std::locale();
|
||||
const std::locale utf8Locale(globalLocale, new boost::filesystem::detail::utf8_codecvt_facet);
|
||||
path::imbue(utf8Locale);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
boost::filesystem::path getBinPath();
|
||||
boost::filesystem::path getBinDirectory();
|
||||
boost::filesystem::path getTempFilePath();
|
||||
std::filesystem::path getBinPath();
|
||||
std::filesystem::path getBinDirectory();
|
||||
std::filesystem::path getTempFilePath();
|
||||
|
||||
std::tm getLocalTime(const time_t& time);
|
||||
std::string errorNumberToString(int errorNumber);
|
||||
|
@ -14,4 +15,3 @@ std::string errorNumberToString(int errorNumber);
|
|||
std::vector<std::string> argsToUtf8(int argc, char* argv[]);
|
||||
|
||||
void useUtf8ForConsole();
|
||||
void useUtf8ForBoostFilesystem();
|
|
@ -1,18 +1,17 @@
|
|||
#include "textFiles.h"
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <format.h>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <fstream>
|
||||
#include "stringTools.h"
|
||||
|
||||
using std::string;
|
||||
using boost::filesystem::path;
|
||||
using std::filesystem::path;
|
||||
|
||||
string readUtf8File(path filePath) {
|
||||
if (!exists(filePath)) {
|
||||
throw std::invalid_argument(fmt::format("File {} does not exist.", filePath));
|
||||
throw std::invalid_argument(fmt::format("File {} does not exist.", filePath.u8string()));
|
||||
}
|
||||
try {
|
||||
boost::filesystem::ifstream file;
|
||||
std::ifstream file;
|
||||
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
file.open(filePath);
|
||||
string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||
|
@ -22,7 +21,7 @@ string readUtf8File(path filePath) {
|
|||
|
||||
return text;
|
||||
} catch (...) {
|
||||
std::throw_with_nested(std::runtime_error(fmt::format("Error reading file {0}.", filePath)));
|
||||
std::throw_with_nested(std::runtime_error(fmt::format("Error reading file {0}.", filePath.u8string())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
std::string readUtf8File(boost::filesystem::path filePath);
|
||||
std::string readUtf8File(std::filesystem::path filePath);
|
Loading…
Reference in New Issue