mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
AK: Add LexicalPath::is_root()
This commit is contained in:
@@ -45,6 +45,11 @@ bool LexicalPath::is_absolute_path(StringView path)
|
||||
return path.length() >= 2 && path[1] == ':';
|
||||
}
|
||||
|
||||
bool LexicalPath::is_root() const
|
||||
{
|
||||
return AK::is_root(m_parts);
|
||||
}
|
||||
|
||||
Vector<ByteString> LexicalPath::parts() const
|
||||
{
|
||||
Vector<ByteString> vector;
|
||||
@@ -81,7 +86,7 @@ ByteString LexicalPath::canonicalized_path(ByteString path)
|
||||
continue;
|
||||
if (part == ".." && !canonical_parts.is_empty()) {
|
||||
// At the root, .. does nothing.
|
||||
if (is_root(canonical_parts))
|
||||
if (AK::is_root(canonical_parts))
|
||||
continue;
|
||||
// A .. and a previous non-.. part cancel each other.
|
||||
if (canonical_parts.last() != "..") {
|
||||
@@ -95,7 +100,7 @@ ByteString LexicalPath::canonicalized_path(ByteString path)
|
||||
StringBuilder builder;
|
||||
builder.join('\\', canonical_parts);
|
||||
// "X:" -> "X:\"
|
||||
if (is_root(canonical_parts))
|
||||
if (AK::is_root(canonical_parts))
|
||||
builder.append('\\');
|
||||
path = builder.to_byte_string();
|
||||
return path == "" ? "." : path;
|
||||
|
||||
Reference in New Issue
Block a user