mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibCore: Add a Resource method to create a file:// URL from a resource
This commit is contained in:
parent
e9aa72ee98
commit
aa9387c76c
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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue