2011-08-26 17:40:23 +00:00
|
|
|
#include "AppInfo.h"
|
|
|
|
|
2011-08-29 21:27:55 +00:00
|
|
|
#include "FileUtils.h"
|
2011-08-29 13:44:08 +00:00
|
|
|
#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
|
|
|
|
}
|
|
|
|
|
2011-08-26 17:40:23 +00:00
|
|
|
std::string AppInfo::logFilePath()
|
|
|
|
{
|
2011-08-29 13:44:08 +00:00
|
|
|
return appDataPath(organizationName(),appName()) + '/' + "update-log.txt";
|
2011-08-26 17:40:23 +00:00
|
|
|
}
|
|
|
|
|
2011-08-29 17:57:12 +00:00
|
|
|
std::string AppInfo::updateErrorMessage(const std::string& details)
|
|
|
|
{
|
|
|
|
std::string result = "There was a problem installing the update:\n\n";
|
|
|
|
result += details;
|
|
|
|
result += "\n\nYou can try downloading and installing the latest version of "
|
|
|
|
"Mendeley Desktop from http://www.mendeley.com/download-mendeley-desktop";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|