diff --git a/base/base_file_utilities.cpp b/base/base_file_utilities.cpp index 640c7313..77808356 100644 --- a/base/base_file_utilities.cpp +++ b/base/base_file_utilities.cpp @@ -37,11 +37,15 @@ QString FileNameFromUserString(QString name) { return Platform::FileNameFromUserString(std::move(name)); } -void RegisterBundledResources(const QString &name) { - const auto location = Platform::BundledResourcesPath(); - if (!QResource::registerResource(location + '/' + name)) { - Unexpected("Packed resources not found."); +void RegisterResourceArchive(const QString &name) { +#ifdef DESKTOP_APP_USE_PACKED_RESOURCES + for (const QString &location : Platform::PackedResourcesPaths()) { + if (QResource::registerResource(location + '/' + name)) { + return; // found + } } + Unexpected("Packed resources not found."); +#endif // DESKTOP_APP_USE_PACKED_RESOURCES } } // namespace base diff --git a/base/base_file_utilities.h b/base/base_file_utilities.h index 867947d0..c7d6d086 100644 --- a/base/base_file_utilities.h +++ b/base/base_file_utilities.h @@ -10,6 +10,6 @@ namespace base { [[nodiscard]] QString FileNameFromUserString(QString name); -void RegisterBundledResources(const QString &name); +void RegisterResourceArchive(const QString &name); } // namespace base diff --git a/base/platform/base_platform_file_utilities.h b/base/platform/base_platform_file_utilities.h index 1ace6342..9441d1d8 100644 --- a/base/platform/base_platform_file_utilities.h +++ b/base/platform/base_platform_file_utilities.h @@ -18,7 +18,7 @@ bool DeleteDirectory(QString path); void RemoveQuarantine(const QString &path); [[nodiscard]] QString CurrentExecutablePath(int argc, char *argv[]); -[[nodiscard]] QString BundledResourcesPath(); +[[nodiscard]] QStringList PackedResourcesPaths(); bool RenameWithOverwrite(const QString &from, const QString &to); void FlushFileData(QFile &file); diff --git a/base/platform/linux/base_file_utilities_linux.cpp b/base/platform/linux/base_file_utilities_linux.cpp index aa65e5ee..d731155c 100644 --- a/base/platform/linux/base_file_utilities_linux.cpp +++ b/base/platform/linux/base_file_utilities_linux.cpp @@ -8,6 +8,7 @@ #include "base/platform/base_platform_file_utilities.h" #include "base/algorithm.h" +#include "base/integration.h" #include #include @@ -216,8 +217,13 @@ QString CurrentExecutablePath(int argc, char *argv[]) { void RemoveQuarantine(const QString &path) { } -QString BundledResourcesPath() { - Unexpected("BundledResourcesPath not implemented."); +QStringList PackedResourcesPaths() { + QStringList l; +#ifdef _DEBUG + l += Integration::Instance().executableDir(); +#endif + l += QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); + return l; } // From http://stackoverflow.com/questions/2256945/removing-a-non-empty-directory-programmatically-in-c-or-c diff --git a/base/platform/mac/base_file_utilities_mac.mm b/base/platform/mac/base_file_utilities_mac.mm index 750e844b..fda3a996 100644 --- a/base/platform/mac/base_file_utilities_mac.mm +++ b/base/platform/mac/base_file_utilities_mac.mm @@ -37,7 +37,7 @@ void RemoveQuarantine(const QString &path) { removexattr(local.data(), kQuarantineAttribute, 0); } -QString BundledResourcesPath() { +QStringList PackedResourcesPaths() { @autoreleasepool { NSString *path = @""; @@ -47,7 +47,7 @@ QString BundledResourcesPath() { Unexpected("Could not get bundled path!"); } path = [path stringByAppendingString:@"/Contents/Resources"]; - return QFile::decodeName([path fileSystemRepresentation]); + return { QFile::decodeName([path fileSystemRepresentation]) }; } @catch (NSException *exception) { Unexpected("Exception in resource registering."); diff --git a/base/platform/win/base_file_utilities_win.cpp b/base/platform/win/base_file_utilities_win.cpp index 9377cfe0..c2140a20 100644 --- a/base/platform/win/base_file_utilities_win.cpp +++ b/base/platform/win/base_file_utilities_win.cpp @@ -8,6 +8,7 @@ #include "base/platform/win/base_windows_safe_library.h" #include "base/algorithm.h" +#include "base/integration.h" #include #include @@ -142,8 +143,9 @@ bool DeleteDirectory(QString path) { void RemoveQuarantine(const QString &path) { } -QString BundledResourcesPath() { - Unexpected("BundledResourcesPath not implemented."); +QStringList PackedResourcesPaths() { + // Is verification of loaded resources really needed? + return { Integration::Instance().executableDir() }; } QString CurrentExecutablePath(int argc, char *argv[]) {