@@ -2067,18 +2067,33 @@ std::string DefaultHomePath()
20672067#ifdef __APPLE__
20682068 return std::string (home) + " /Library/Application Support/" PRODUCT_NAME;
20692069#else
2070- struct stat stl, stx;
2071-
2072- std::string legacyHomePath = Path::Build (std::string (home), " ." PRODUCT_NAME_LOWER);
20732070 const char * _xdgDataHome = getenv (" XDG_DATA_HOME" );
2074- std::string xdgDataHome = _xdgDataHome == NULL ? " " : std::string (_xdgDataHome);
2071+ std::string xdgDataHome = _xdgDataHome == NULL ? Path::Build ( Path::Build ( std::string (home), " .local " ) , " share " ) : std::string (_xdgDataHome);
20752072 std::string xdgHomePath;
20762073
2077- if (xdgDataHome.empty ()) {
2078- xdgDataHome = Path::Build (Path::Build (std::string (home), " .local" ) ," share" );
2074+ xdgHomePath = Path::Build (xdgDataHome, PRODUCT_NAME_LOWER);
2075+
2076+ return xdgHomePath;
2077+ #endif
2078+ #endif
2079+ }
2080+
2081+ void MigrateHomePath ()
2082+ {
2083+ #if defined(__linux__)
2084+ const char * home = getenv (" HOME" );
2085+ if (!home) {
2086+ // in this case DefaultHomePath() will return "",
2087+ // hence homePath will be neither the legacy one
2088+ // neither the xdg one, hence there is nothing we can do.
2089+ return ;
20792090 }
20802091
2081- xdgHomePath = Path::Build (xdgDataHome, PRODUCT_NAME_LOWER);
2092+ const char * _xdgDataHome = getenv (" XDG_DATA_HOME" );
2093+ std::string xdgDataHome = _xdgDataHome == NULL ? Path::Build (Path::Build (std::string (home), " .local" ) ," share" ) : std::string (_xdgDataHome);
2094+ std::string xdgHomePath = DefaultHomePath ();
2095+ std::string legacyHomePath = Path::Build (std::string (home), " ." PRODUCT_NAME_LOWER);
2096+ struct stat stl, stx;
20822097
20832098 if (lstat (legacyHomePath.c_str (), &stl) == 0 ) {
20842099 if (S_ISDIR (stl.st_mode ) || S_ISLNK (stl.st_mode )) {
@@ -2118,9 +2133,6 @@ std::string DefaultHomePath()
21182133 }
21192134 }
21202135 }
2121-
2122- return xdgHomePath;
2123- #endif
21242136#endif
21252137}
21262138#endif // BUILD_VM
0 commit comments