mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-05 05:44:13 +00:00
Custom datadir + cleanup
This commit is contained in:
parent
56f1f627ef
commit
2fd31c6c8d
11
i2p.cpp
11
i2p.cpp
@ -24,16 +24,7 @@ int main( int argc, char* argv[] )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
LogPrint("\n\n\n\ni2pd starting\n");
|
LogPrint("\n\n\n\ni2pd starting\n");
|
||||||
LogPrint("default data directory: ", i2p::util::filesystem::GetDefaultDataDir().string());
|
LogPrint("data directory: ", i2p::util::filesystem::GetDataDir().string());
|
||||||
if (!boost::filesystem::exists( i2p::util::filesystem::GetDefaultDataDir() ))
|
|
||||||
{
|
|
||||||
// Create data directory
|
|
||||||
if (!boost::filesystem::create_directory( i2p::util::filesystem::GetDefaultDataDir() ))
|
|
||||||
{
|
|
||||||
LogPrint("Failed to create data directory, exiting! :(");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs);
|
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs);
|
||||||
|
|
||||||
//TODO: This is an ugly workaround. fix it.
|
//TODO: This is an ugly workaround. fix it.
|
||||||
|
27
util.cpp
27
util.cpp
@ -89,30 +89,37 @@ namespace config
|
|||||||
|
|
||||||
namespace filesystem
|
namespace filesystem
|
||||||
{
|
{
|
||||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
const boost::filesystem::path &GetDataDir()
|
||||||
{
|
{
|
||||||
|
|
||||||
static boost::filesystem::path path;
|
static boost::filesystem::path path;
|
||||||
|
|
||||||
if (config::mapArgs.count("-datadir")) {
|
if (i2p::util::config::mapArgs.count("-datadir")) {
|
||||||
path = boost::filesystem::system_complete(config::mapArgs["-datadir"]);
|
path = boost::filesystem::system_complete(i2p::util::config::mapArgs["-datadir"]);
|
||||||
if (!boost::filesystem::is_directory(path)) {
|
|
||||||
path = "";
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
path = GetDefaultDataDir();
|
path = GetDefaultDataDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::create_directory(path);
|
if (!boost::filesystem::exists( path ))
|
||||||
|
{
|
||||||
|
// Create data directory
|
||||||
|
if (!boost::filesystem::create_directory( path ))
|
||||||
|
{
|
||||||
|
LogPrint("Failed to create data directory!");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!boost::filesystem::is_directory(path)) {
|
||||||
|
path = GetDefaultDataDir();
|
||||||
|
}
|
||||||
|
LogPrint("Debug: ",path.string());
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path GetConfigFile()
|
boost::filesystem::path GetConfigFile()
|
||||||
{
|
{
|
||||||
boost::filesystem::path pathConfigFile(i2p::util::config::GetArg("-conf", "i2p.conf"));
|
boost::filesystem::path pathConfigFile(i2p::util::config::GetArg("-conf", "i2p.conf"));
|
||||||
if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile;
|
if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir() / pathConfigFile;
|
||||||
return pathConfigFile;
|
return pathConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
util.h
1
util.h
@ -22,6 +22,7 @@ namespace util
|
|||||||
|
|
||||||
namespace filesystem
|
namespace filesystem
|
||||||
{
|
{
|
||||||
|
const boost::filesystem::path &GetDataDir();
|
||||||
boost::filesystem::path GetDefaultDataDir();
|
boost::filesystem::path GetDefaultDataDir();
|
||||||
boost::filesystem::path GetConfigFile();
|
boost::filesystem::path GetConfigFile();
|
||||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
|
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user