Browse Source

specify application name

pull/113/head
orignal 10 years ago
parent
commit
2988395b81
  1. 4
      api/api.cpp
  2. 20
      util.cpp
  3. 3
      util.h

4
api/api.cpp

@ -18,14 +18,14 @@ namespace api @@ -18,14 +18,14 @@ namespace api
void InitI2P (int argc, char* argv[])
{
i2p::util::filesystem::SetAppName (argv[0]);
i2p::util::config::OptionParser(argc, argv);
i2p::context.Init ();
}
void StartI2P ()
{
std::string logfilePath ("libi2pd.log");
StartLog (logfilePath);
StartLog (i2p::util::filesystem::GetAppName () + ".log");
i2p::data::netdb.Start();
LogPrint("NetDB started");
i2p::transport::transports.Start();

20
util.cpp

@ -101,6 +101,18 @@ namespace config @@ -101,6 +101,18 @@ namespace config
namespace filesystem
{
std::string appName ("i2pd");
void SetAppName (const std::string& name)
{
appName = name;
}
std::string GetAppName ()
{
return appName;
}
const boost::filesystem::path &GetDataDir()
{
static boost::filesystem::path path;
@ -178,10 +190,10 @@ namespace filesystem @@ -178,10 +190,10 @@ namespace filesystem
// Windows
char localAppData[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_APPDATA, 0, NULL, localAppData);
return boost::filesystem::path(std::string(localAppData) + "\\i2pd");
return boost::filesystem::path(std::string(localAppData) + "\\" + appName);
#else
if (i2p::util::config::GetArg("-service", 0)) // use system folder
return boost::filesystem::path("/var/lib/i2pd");
return boost::filesystem::path(std::string ("/var/lib/") + appName);
boost::filesystem::path pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
@ -192,10 +204,10 @@ namespace filesystem @@ -192,10 +204,10 @@ namespace filesystem
// Mac
pathRet /= "Library/Application Support";
boost::filesystem::create_directory(pathRet);
return pathRet / "i2pd";
return pathRet / appName;
#else
// Unix
return pathRet / ".i2pd";
return pathRet / (std::string (".") + appName);
#endif
#endif
}

3
util.h

@ -25,6 +25,9 @@ namespace util @@ -25,6 +25,9 @@ namespace util
namespace filesystem
{
void SetAppName (const std::string& name);
std::string GetAppName ();
const boost::filesystem::path &GetDataDir();
std::string GetFullPath (const std::string& filename);
boost::filesystem::path GetDefaultDataDir();

Loading…
Cancel
Save