Store update-log.txt log file in the correct location under Windows

This is the same location that Mendeley Desktop stores its data files
($LOCAL_APPDATA/$ORGANIZATION_NAME/$APP_NAME)
This commit is contained in:
Robert Knight 2011-08-30 10:43:14 +01:00
parent 56e476b33d
commit 9d3c02e31c
2 changed files with 22 additions and 5 deletions

View file

@ -4,11 +4,17 @@
#include "Platform.h"
#include "StringUtils.h"
#include <iostream>
#ifdef PLATFORM_UNIX
#include <stdlib.h>
#include <pwd.h>
#endif
#ifdef PLATFORM_WINDOWS
#include <shlobj.h>
#endif
#ifdef PLATFORM_UNIX
std::string homeDir()
{
@ -43,7 +49,17 @@ std::string appDataPath(const std::string& organizationName,
// TODO - Mac implementation
#elif defined(PLATFORM_WINDOWS)
// TODO - Windows implementation
char buffer[MAX_PATH+1];
if (SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0 /* hToken */, SHGFP_TYPE_CURRENT, buffer) == S_OK)
{
std::string path = FileUtils::toUnixPathSeparators(notNullString(buffer));
path += '/' + organizationName + '/' + appName;
return path;
}
else
{
return std::string();
}
#endif
}

View file

@ -92,11 +92,12 @@ class FileUtils
*/
static void extractFromZip(const char* zipFile, const char* src, const char* dest) throw (IOException);
/** Returns a copy of the path 'str' with Windows-style '\'
* dir separators converted to Unix-style '/' separators
*/
static std::string toUnixPathSeparators(const std::string& str);
private:
static int toUnixPermissions(int qtPermissions);
// returns a copy of the path 'str' with Windows-style '\'
// dir separators converted to Unix-style '/' separators
static std::string toUnixPathSeparators(const std::string& str);
};