mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-10 06:31:49 +00:00
Log update installation details to update-log.txt in the correct Mendeley data directory under Linux
This commit is contained in:
parent
0d22024b49
commit
f9238f479b
2 changed files with 54 additions and 1 deletions
|
@ -1,7 +1,54 @@
|
|||
#include "AppInfo.h"
|
||||
|
||||
#include "FileOps.h"
|
||||
#include "Platform.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_UNIX
|
||||
std::string homeDir()
|
||||
{
|
||||
std::string dir = notNullString(getenv("HOME"));
|
||||
if (!dir.empty())
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
// note: if this process has been elevated with sudo,
|
||||
// this will return the home directory of the root user
|
||||
struct passwd* userData = getpwuid(getuid());
|
||||
return notNullString(userData->pw_dir);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string appDataPath(const std::string& organizationName,
|
||||
const std::string& appName)
|
||||
{
|
||||
#ifdef PLATFORM_LINUX
|
||||
std::string xdgDataHome = notNullString(getenv("XDG_DATA_HOME"));
|
||||
if (xdgDataHome.empty())
|
||||
{
|
||||
xdgDataHome = homeDir() + "/.local/share";
|
||||
}
|
||||
xdgDataHome += "/data/" + organizationName + '/' + appName;
|
||||
return xdgDataHome;
|
||||
|
||||
#elif defined(PLATFORM_MAC)
|
||||
// TODO - Mac implementation
|
||||
|
||||
#elif defined(PLATFORM_WINDOWS)
|
||||
// TODO - Windows implementation
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string AppInfo::logFilePath()
|
||||
{
|
||||
return "update-log.txt";
|
||||
return appDataPath(organizationName(),appName()) + '/' + "update-log.txt";
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class AppInfo
|
|||
// Basic application information
|
||||
static std::string name();
|
||||
static std::string appName();
|
||||
static std::string organizationName();
|
||||
|
||||
static std::string logFilePath();
|
||||
};
|
||||
|
@ -26,3 +27,8 @@ inline std::string AppInfo::appName()
|
|||
return "Mendeley Desktop";
|
||||
}
|
||||
|
||||
inline std::string AppInfo::organizationName()
|
||||
{
|
||||
return "Mendeley Ltd.";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue