mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
AK: Add dirname() to FileSystemPath
This commit is contained in:
parent
3f3169c225
commit
c7fd39f3b1
Notes:
sideshowbarker
2024-07-19 10:17:32 +09:00
Author: https://github.com/deoxxa
Commit: c7fd39f3b1
Pull-request: https://github.com/SerenityOS/serenity/pull/1035
2 changed files with 12 additions and 1 deletions
|
@ -45,10 +45,19 @@ void FileSystemPath::canonicalize()
|
|||
}
|
||||
}
|
||||
if (canonical_parts.is_empty()) {
|
||||
m_string = m_basename = "/";
|
||||
m_string = m_basename = m_dirname = "/";
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder dirname_builder(approximate_canonical_length);
|
||||
for (int i = 0; i < canonical_parts.size() - 1; ++i) {
|
||||
auto& canonical_part = canonical_parts[i];
|
||||
if (is_absolute_path || i != 0)
|
||||
dirname_builder.append('/');
|
||||
dirname_builder.append(canonical_part);
|
||||
}
|
||||
m_dirname = dirname_builder.to_string();
|
||||
|
||||
m_basename = canonical_parts.last();
|
||||
auto name_parts = m_basename.split('.');
|
||||
m_title = name_parts[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue