Switch to fs::path where appropriate.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
tastytea 2021-05-20 10:20:19 +02:00
parent f57555fb3a
commit cf8fb95777
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 9 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <cstdlib> #include <cstdlib>
#include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -32,6 +33,7 @@ namespace epubgrep
{ {
namespace po = boost::program_options; namespace po = boost::program_options;
namespace fs = std::filesystem;
using boost::locale::translate; using boost::locale::translate;
using std::cout; using std::cout;
@ -83,7 +85,7 @@ po::variables_map parse_options(int argc, char *argv[])
return vm; return vm;
} }
std::string get_config_path() fs::path get_config_path()
{ {
auto get_env = [](std::string const &name) auto get_env = [](std::string const &name)
{ {
@ -96,21 +98,21 @@ std::string get_config_path()
return ""; return "";
}; };
std::string path{get_env("XDG_CONFIG_HOME")}; fs::path path{get_env("XDG_CONFIG_HOME")};
if (path.empty()) if (path.empty())
{ {
path = get_env("HOME"); path = get_env("HOME");
if (!path.empty()) if (!path.empty())
{ {
path += "/.config"; path /= ".config";
} }
} }
if (!path.empty()) if (!path.empty())
{ {
path += "/"; return path /= "epubgrep.conf";
} }
return path += "epubgrep.conf"; return "epubgrep.conf";
} }
} // namespace epubgrep } // namespace epubgrep

View File

@ -19,7 +19,7 @@
#include <boost/program_options/variables_map.hpp> #include <boost/program_options/variables_map.hpp>
#include <string> #include <filesystem>
namespace epubgrep namespace epubgrep
{ {
@ -36,7 +36,7 @@ po::variables_map parse_options(int argc, char *argv[]);
* If HOME is set: ${HOME}/.config/epubgrep.conf * If HOME is set: ${HOME}/.config/epubgrep.conf
* Otherwise: epubgrep.conf * Otherwise: epubgrep.conf
*/ */
std::string get_config_path(); std::filesystem::path get_config_path();
} // namespace epubgrep } // namespace epubgrep