mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibCore: Add modified time to Resource
For now, all Resources are implemented with a modification time, but the public API has been left as an Optional since abstractly, not all resources will have a modification time.
This commit is contained in:
parent
e3ef849838
commit
28307d0db6
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/shannonbooth
Commit: 28307d0db6
Pull-request: https://github.com/SerenityOS/serenity/pull/23799
5 changed files with 36 additions and 33 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/ResourceImplementationFile.h>
|
||||
#include <LibCore/System.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -25,10 +26,13 @@ ErrorOr<NonnullRefPtr<Resource>> ResourceImplementationFile::load_from_resource_
|
|||
|
||||
auto path = TRY(String::from_utf8(uri.substring_view(resource_scheme.length())));
|
||||
auto full_path = TRY(String::from_byte_string(LexicalPath::join(m_base_directory, path).string()));
|
||||
if (is_directory(full_path))
|
||||
return make_directory_resource(move(path));
|
||||
|
||||
return make_resource(path, TRY(MappedFile::map(full_path)));
|
||||
auto st = TRY(System::stat(full_path));
|
||||
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return make_directory_resource(move(path), st.st_mtime);
|
||||
|
||||
return make_resource(path, TRY(MappedFile::map(full_path)), st.st_mtime);
|
||||
}
|
||||
|
||||
Vector<String> ResourceImplementationFile::child_names_for_resource_scheme(Resource const& resource)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue