rework of storing certificates path (#1642)

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2021-06-18 10:04:48 +03:00
parent d3a49e513c
commit e8ad7b4f79
No known key found for this signature in database
GPG key ID: 66F6C87B98EBCFE2
5 changed files with 45 additions and 15 deletions

View file

@ -24,6 +24,7 @@ namespace i2p {
namespace fs {
std::string appName = "i2pd";
std::string dataDir = "";
std::string certsDir = "";
#ifdef _WIN32
std::string dirSep = "\\";
#else
@ -42,6 +43,10 @@ namespace fs {
return dataDir;
}
const std::string & GetCertsDir () {
return certsDir;
}
const std::string GetUTF8DataDir () {
#ifdef _WIN32
boost::filesystem::wpath path (dataDir);
@ -126,6 +131,21 @@ namespace fs {
#endif
}
void SetCertsDir(const std::string & cmdline_certsdir) {
if (cmdline_certsdir != "")
{
if (cmdline_certsdir[cmdline_certsdir.length()-1] == '/')
certsDir = cmdline_certsdir.substr(0, cmdline_certsdir.size()-1); // strip trailing slash
else
certsDir = cmdline_certsdir;
}
else
{
certsDir = i2p::fs::DataDirPath("certificates");
}
return;
}
bool Init() {
if (!boost::filesystem::exists(dataDir))
boost::filesystem::create_directory(dataDir);