mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Add dirs migration
This commit is contained in:
parent
0899262585
commit
d86c0a4313
4 changed files with 56 additions and 0 deletions
|
@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.12)
|
||||||
project(luanti)
|
project(luanti)
|
||||||
set(PROJECT_NAME_CAPITALIZED "Luanti")
|
set(PROJECT_NAME_CAPITALIZED "Luanti")
|
||||||
|
|
||||||
|
set(LEGACY_PROJECT_NAME "minetest")
|
||||||
|
set(LEGACY_PROJECT_NAME_CAPITALIZED "Minetest")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(GCC_MINIMUM_VERSION "7.5")
|
set(GCC_MINIMUM_VERSION "7.5")
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#define PROJECT_NAME "@PROJECT_NAME@"
|
#define PROJECT_NAME "@PROJECT_NAME@"
|
||||||
#define PROJECT_NAME_C "@PROJECT_NAME_CAPITALIZED@"
|
#define PROJECT_NAME_C "@PROJECT_NAME_CAPITALIZED@"
|
||||||
|
#define LEGACY_PROJECT_NAME "@LEGACY_PROJECT_NAME@"
|
||||||
|
#define LEGACY_PROJECT_NAME_C "@LEGACY_PROJECT_NAME_CAPITALIZED@"
|
||||||
#define VERSION_MAJOR @VERSION_MAJOR@
|
#define VERSION_MAJOR @VERSION_MAJOR@
|
||||||
#define VERSION_MINOR @VERSION_MINOR@
|
#define VERSION_MINOR @VERSION_MINOR@
|
||||||
#define VERSION_PATCH @VERSION_PATCH@
|
#define VERSION_PATCH @VERSION_PATCH@
|
||||||
|
|
|
@ -457,6 +457,17 @@ bool setSystemPaths()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateLegacyDirs() {
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
|
DWORD len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf));
|
||||||
|
FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA");
|
||||||
|
std::string legacy_path_user = std::string(buf) + DIR_DELIM LEGACY_PROJECT_NAME_C;
|
||||||
|
std::string new_path_user = std::string(buf) + DIR_DELIM PROJECT_NAME_C;
|
||||||
|
|
||||||
|
if (fs::PathExists(legacy_path_user))
|
||||||
|
fs::MoveDir(legacy_path_user, new_path_user);
|
||||||
|
}
|
||||||
|
|
||||||
//// Android
|
//// Android
|
||||||
|
|
||||||
|
@ -525,6 +536,21 @@ bool setSystemPaths()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateLegacyDirs() {
|
||||||
|
const char *const xdg_data = getenv("XDG_DATA_HOME");
|
||||||
|
std::string legacy_path_user;
|
||||||
|
std::string new_path_user;
|
||||||
|
|
||||||
|
legacy_path_user = std::string(getHomeOrFail()) + DIR_DELIM "." LEGACY_PROJECT_NAME;
|
||||||
|
if (xdg_data) {
|
||||||
|
new_path_user = std::string(xdg_data);
|
||||||
|
} else {
|
||||||
|
new_path_user = std::string(getHomeOrFail()) + DIR_DELIM ".local" DIR_DELIM "share" DIR_DELIM PROJECT_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs::PathExists(legacy_path_user))
|
||||||
|
fs::MoveDir(legacy_path_user, new_path_user);
|
||||||
|
}
|
||||||
|
|
||||||
//// Mac OS X
|
//// Mac OS X
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
@ -553,6 +579,18 @@ bool setSystemPaths()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateLegacyDirs() {
|
||||||
|
std::string legacy_path_user = std::string(getHomeOrFail())
|
||||||
|
+ "/Library/Application Support/"
|
||||||
|
LEGACY_PROJECT_NAME;
|
||||||
|
|
||||||
|
std::string new_path_user = std::string(getHomeOrFail())
|
||||||
|
+ "/Library/Application Support/"
|
||||||
|
PROJECT_NAME;
|
||||||
|
|
||||||
|
if (fs::PathExists(legacy_path_user))
|
||||||
|
fs::MoveDir(legacy_path_user, new_path_user);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -568,6 +606,15 @@ bool setSystemPaths()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateLegacyDirs() {
|
||||||
|
std::string legacy_path_user = std::string(getHomeOrFail()) + DIR_DELIM "." LEGACY_PROJECT_NAME;
|
||||||
|
|
||||||
|
std::string new_path_user = std::string(getHomeOrFail()) + DIR_DELIM "." PROJECT_NAME;
|
||||||
|
|
||||||
|
if (fs::PathExists(legacy_path_user))
|
||||||
|
fs::MoveDir(legacy_path_user, new_path_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -682,6 +729,8 @@ void initializePaths()
|
||||||
// Migrate cache folder to new location if possible
|
// Migrate cache folder to new location if possible
|
||||||
migrateCachePath();
|
migrateCachePath();
|
||||||
|
|
||||||
|
migrateLegacyDirs();
|
||||||
|
|
||||||
#endif // RUN_IN_PLACE
|
#endif // RUN_IN_PLACE
|
||||||
|
|
||||||
assert(!path_share.empty());
|
assert(!path_share.empty());
|
||||||
|
|
|
@ -119,6 +119,8 @@ std::string getDataPath(const char *subpath);
|
||||||
*/
|
*/
|
||||||
void initializePaths();
|
void initializePaths();
|
||||||
|
|
||||||
|
void migrateLegacyDirs();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return system information
|
Return system information
|
||||||
e.g. "Linux/3.12.7 x86_64"
|
e.g. "Linux/3.12.7 x86_64"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue