mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-17 00:23:00 +00:00
AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used. Instead of having valid/invalid states and storing an error in case it's invalid, a MappedFile is now always valid, and the factory function that creates it will return an OSError if mapping fails.
This commit is contained in:
parent
70fce5c4c7
commit
2f3b901f7f
Notes:
sideshowbarker
2024-07-18 23:57:45 +09:00
Author: https://github.com/awesomekling
Commit: 2f3b901f7f
36 changed files with 184 additions and 199 deletions
|
@ -162,8 +162,9 @@ static String folder_image_data()
|
|||
{
|
||||
static String cache;
|
||||
if (cache.is_empty()) {
|
||||
MappedFile image("/res/icons/16x16/filetype-folder.png");
|
||||
cache = encode_base64({ image.data(), image.size() });
|
||||
auto file_or_error = MappedFile::map("/res/icons/16x16/filetype-folder.png");
|
||||
ASSERT(!file_or_error.is_error());
|
||||
cache = encode_base64(file_or_error.value()->bytes());
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
@ -172,8 +173,9 @@ static String file_image_data()
|
|||
{
|
||||
static String cache;
|
||||
if (cache.is_empty()) {
|
||||
MappedFile image("/res/icons/16x16/filetype-unknown.png");
|
||||
cache = encode_base64({ image.data(), image.size() });
|
||||
auto file_or_error = MappedFile::map("/res/icons/16x16/filetype-unknown.png");
|
||||
ASSERT(!file_or_error.is_error());
|
||||
cache = encode_base64(file_or_error.value()->bytes());
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue