mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
53
Libraries/LibCore/ResourceImplementationFile.cpp
Normal file
53
Libraries/LibCore/ResourceImplementationFile.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/ResourceImplementationFile.h>
|
||||
#include <LibCore/System.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
ResourceImplementationFile::ResourceImplementationFile(String base_directory)
|
||||
: m_base_directory(move(base_directory))
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Resource>> ResourceImplementationFile::load_from_resource_scheme_uri(StringView uri)
|
||||
{
|
||||
StringView const resource_scheme = "resource://"sv;
|
||||
|
||||
VERIFY(uri.starts_with(resource_scheme));
|
||||
|
||||
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()));
|
||||
|
||||
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)
|
||||
{
|
||||
Vector<String> children;
|
||||
Core::DirIterator it(resource.filesystem_path().to_byte_string(), Core::DirIterator::SkipParentAndBaseDir);
|
||||
while (it.has_next())
|
||||
children.append(MUST(String::from_byte_string(it.next_path())));
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
String ResourceImplementationFile::filesystem_path_for_resource_scheme(String const& relative_path)
|
||||
{
|
||||
return MUST(String::from_byte_string(LexicalPath::join(m_base_directory, relative_path).string()));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue