feat(GODT-2373): introducing bridgelib Go dynamic library in bridge-gui.

This commit is contained in:
Xavier Michelon
2023-02-17 16:47:35 +01:00
parent cf8284a489
commit a741ffb595
31 changed files with 1457 additions and 1305 deletions

View File

@ -65,131 +65,6 @@ std::mt19937_64 &rng() {
} // anonymous namespace
//****************************************************************************************************************************************************
/// \return user configuration directory used by bridge (based on Golang OS/File's UserConfigDir).
//****************************************************************************************************************************************************
QString userConfigDir() {
QString dir;
#ifdef Q_OS_WIN
dir = qgetenv ("AppData");
if (dir.isEmpty())
throw Exception("%AppData% is not defined.");
#elif defined(Q_OS_IOS) || defined(Q_OS_DARWIN)
dir = qgetenv("HOME");
if (dir.isEmpty()) {
throw Exception("$HOME is not defined.");
}
dir += "/Library/Application Support";
#else
dir = qgetenv ("XDG_CONFIG_HOME");
if (dir.isEmpty())
{
dir = qgetenv ("HOME");
if (dir.isEmpty())
throw Exception("neither $XDG_CONFIG_HOME nor $HOME are defined");
dir += "/.config";
}
#endif
QString const folder = QDir(dir).absoluteFilePath(configFolder);
QDir().mkpath(folder);
return folder;
}
//****************************************************************************************************************************************************
/// \return user cache directory used by bridge (based on Golang OS/File's UserCacheDir).
//****************************************************************************************************************************************************
QString userCacheDir() {
QString dir;
#ifdef Q_OS_WIN
dir = qgetenv ("LocalAppData");
if (dir.isEmpty())
throw Exception("%LocalAppData% is not defined.");
#elif defined(Q_OS_IOS) || defined(Q_OS_DARWIN)
dir = qgetenv("HOME");
if (dir.isEmpty()) {
throw Exception("$HOME is not defined.");
}
dir += "/Library/Caches";
#else
dir = qgetenv ("XDG_CACHE_HOME");
if (dir.isEmpty())
{
dir = qgetenv ("HOME");
if (dir.isEmpty())
throw Exception("neither $XDG_CACHE_HOME nor $HOME are defined");
dir += "/.cache";
}
#endif
QString const folder = QDir(dir).absoluteFilePath(configFolder);
QDir().mkpath(folder);
return folder;
}
//****************************************************************************************************************************************************
/// \return user data directory used by bridge (based on Golang OS/File's UserDataDir).
//****************************************************************************************************************************************************
QString userDataDir() {
QString folder;
#ifdef Q_OS_LINUX
QString dir = qgetenv ("XDG_DATA_HOME");
if (dir.isEmpty())
{
dir = qgetenv ("HOME");
if (dir.isEmpty())
throw Exception("neither $XDG_DATA_HOME nor $HOME are defined");
dir += "/.local/share";
}
folder = QDir(dir).absoluteFilePath(configFolder);
QDir().mkpath(folder);
#else
folder = userConfigDir();
#endif
return folder;
}
//****************************************************************************************************************************************************
/// \return user logs directory used by bridge.
//****************************************************************************************************************************************************
QString userLogsDir() {
QString const path = QDir(userDataDir()).absoluteFilePath("logs");
QDir().mkpath(path);
return path;
}
//****************************************************************************************************************************************************
/// \return sentry cache directory used by bridge.
//****************************************************************************************************************************************************
QString sentryCacheDir() {
QString const path = QDir(userDataDir()).absoluteFilePath("sentry_cache");
QDir().mkpath(path);
return path;
}
//****************************************************************************************************************************************************
/// \return The value GOOS would return for the current platform.
//****************************************************************************************************************************************************
QString goos() {
#if defined(Q_OS_DARWIN)
return "darwin";
#elif defined(Q_OS_WINDOWS)
return "windows";
#else
return "linux";
#endif
}
//****************************************************************************************************************************************************
/// Slow, but not biased. Not for use in crypto functions though, as the RNG use std::random_device as a seed.
///