Fix icon loading for third-party apps with file:// URL scheme
- Add file:// URL handling to AssetFilesInterface in kernel.cpp - Update home.lua to use file:// prefix for absolute filesystem paths - Add file:// URL handling to desktop file interface for consistency This fixes RmlUi stripping the leading slash from absolute paths when resolving img src URLs relative to the document base. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,9 +66,17 @@ public:
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Check if path is a filesystem path (starts with /)
|
||||
// Check if path is a filesystem path (starts with / or file://)
|
||||
static bool IsFilesystemPath(const Rml::String& path) {
|
||||
return !path.empty() && path[0] == '/';
|
||||
return !path.empty() && (path[0] == '/' || path.rfind("file://", 0) == 0);
|
||||
}
|
||||
|
||||
// Get the actual filesystem path, stripping file:// prefix if present
|
||||
static Rml::String GetFilesystemPath(const Rml::String& path) {
|
||||
if (path.rfind("file://", 0) == 0) {
|
||||
return path.substr(7); // Strip "file://"
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
Rml::FileHandle Open(const Rml::String &path) override
|
||||
@@ -77,7 +85,8 @@ public:
|
||||
|
||||
if (IsFilesystemPath(path)) {
|
||||
// Filesystem path
|
||||
auto* file = new std::ifstream(path, std::ios::binary);
|
||||
Rml::String fs_path = GetFilesystemPath(path);
|
||||
auto* file = new std::ifstream(fs_path, std::ios::binary);
|
||||
if (!file->is_open()) {
|
||||
delete file;
|
||||
delete wrapper;
|
||||
@@ -175,7 +184,8 @@ public:
|
||||
{
|
||||
if (IsFilesystemPath(path)) {
|
||||
// Load from filesystem
|
||||
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
||||
Rml::String fs_path = GetFilesystemPath(path);
|
||||
std::ifstream file(fs_path, std::ios::binary | std::ios::ate);
|
||||
if (!file.is_open()) return false;
|
||||
|
||||
size_t size = file.tellg();
|
||||
|
||||
Reference in New Issue
Block a user