From cf8fb957772dbec67af3b2edbaca558e87c61070 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 20 May 2021 10:20:19 +0200 Subject: [PATCH] Switch to fs::path where appropriate. --- src/options.cpp | 12 +++++++----- src/options.hpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/options.cpp b/src/options.cpp index 30d6773..a291287 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ namespace epubgrep { namespace po = boost::program_options; +namespace fs = std::filesystem; using boost::locale::translate; using std::cout; @@ -83,7 +85,7 @@ po::variables_map parse_options(int argc, char *argv[]) return vm; } -std::string get_config_path() +fs::path get_config_path() { auto get_env = [](std::string const &name) { @@ -96,21 +98,21 @@ std::string get_config_path() return ""; }; - std::string path{get_env("XDG_CONFIG_HOME")}; + fs::path path{get_env("XDG_CONFIG_HOME")}; if (path.empty()) { path = get_env("HOME"); if (!path.empty()) { - path += "/.config"; + path /= ".config"; } } if (!path.empty()) { - path += "/"; + return path /= "epubgrep.conf"; } - return path += "epubgrep.conf"; + return "epubgrep.conf"; } } // namespace epubgrep diff --git a/src/options.hpp b/src/options.hpp index 425d5be..f623565 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -19,7 +19,7 @@ #include -#include +#include namespace epubgrep { @@ -36,7 +36,7 @@ po::variables_map parse_options(int argc, char *argv[]); * If HOME is set: ${HOME}/.config/epubgrep.conf * Otherwise: epubgrep.conf */ -std::string get_config_path(); +std::filesystem::path get_config_path(); } // namespace epubgrep