From: "Lubomir I. Ivanov" <[email protected]> On Win32 the Roaming path is recommended. The truth is every application picks either the Local or Roaming paths for no particular reason as the the difference is not that great and developers don't understand what Microsoft implied in the context of the paths.
Roaming should be for server-client stuff and small files that are shared i.e. more portable stuff, while Local should be for bigger files and application data storage i.e. you can have your massive game executable in "program files" but all the data like geometry, textures, scripts and shaders in Local. We use Roaming as we don't have huge files, our default user file location is already been there since version 2.0(?) and the default file is quite portable, also the git cache is exactly "roaming" in context and should be there! Qt supporting this from 5.4 is silly, but fortunatelly we build with the latest Qt for Win32. To achieve that we enable the old #ifdef in: system_default_directory() but only use QStandardPaths::AppDataLocation on Win32. Signed-off-by: Lubomir I. Ivanov <[email protected]> --- tested... what i don't get is why Qt applies another Subsurface after the: C:\Users\<name>\AppData\Roaming\Subsurface\ ^Subsurface the default user file path is retrieved in windows.c: system_default_filename() via SHGetFolderPath() with CSIDL_APPDATA. and the return from that is: C:\Users\<name>\AppData\Roaming\Subsurface\ which is what i would expect Qt to return, but it doesn't. this makes the following folder structure: C:\Users\<name>\AppData\Roaming\Subsurface\ <---- path for user files C:\Users\<name>\AppData\Roaming\Subsurface\Subsurface <---- git cache this patch also removes the extra Subsurface on Win32. i would not use Qts methods and add helpers in windows.c/linux.c/macos.c as technically the git-access.c backend needs not to depend on Qt. --- qthelper.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/qthelper.cpp b/qthelper.cpp index ed23948..9d87cd8 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -613,17 +613,28 @@ extern "C" const char *system_default_directory(void) // allegedly once you're on Qt5.4 or later you should use // QStandardPaths::AppDataLocation but on Mac that gives us // paths starting with /Library/... - // #if QT_VERSION >= 0x050400 - // location = QStandardPaths::AppDataLocation; - // #else + #if QT_VERSION >= 0x050400 && defined Q_OS_WIN32 + location = QStandardPaths::AppDataLocation; + #else location = QStandardPaths::DataLocation; - // #endif + #endif + QString name = QStandardPaths::standardLocations(location).first(); + + // why does Qt return the application name twice as path? + // this is not what i would expect from CSIDL_APPDATA + #ifdef Q_OS_WIN32 + const QString appName = "/Subsurface"; + if (name.count(appName) > 1) + name.truncate(name.lastIndexOf(appName)); + #endif + QDir dir(name); dir.mkpath(name); // Why no "dir.encodeName()"? Crazy Qt strncpy(filename, QFile::encodeName(name), PATH_MAX-1); } + return filename; } -- 1.7.11.msysgit.0 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
