LibCore: Add a Resource method to create a file:// URL from a resource
This commit is contained in:
parent
e9aa72ee98
commit
aa9387c76c
Notes:
sideshowbarker
2024-07-17 02:37:08 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/aa9387c76c Pull-request: https://github.com/SerenityOS/serenity/pull/21799
2 changed files with 9 additions and 0 deletions
|
@ -58,6 +58,14 @@ String Resource::filesystem_path() const
|
|||
return ResourceImplementation::the().filesystem_path(*this);
|
||||
}
|
||||
|
||||
String Resource::file_url() const
|
||||
{
|
||||
if (m_scheme == Scheme::File)
|
||||
return uri();
|
||||
|
||||
return MUST(String::formatted("file://{}", filesystem_path()));
|
||||
}
|
||||
|
||||
String Resource::filename() const
|
||||
{
|
||||
return MUST(String::from_utf8(LexicalPath(m_path.bytes_as_string_view()).basename()));
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
[[nodiscard]] String uri() const;
|
||||
[[nodiscard]] String filename() const;
|
||||
[[nodiscard]] String filesystem_path() const;
|
||||
[[nodiscard]] String file_url() const;
|
||||
|
||||
[[nodiscard]] ByteBuffer clone_data() const;
|
||||
[[nodiscard]] ByteBuffer release_data() &&;
|
||||
|
|
Loading…
Add table
Reference in a new issue