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 <cstdlib>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
@ -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

View File

@ -19,7 +19,7 @@
#include <boost/program_options/variables_map.hpp>
#include <string>
#include <filesystem>
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