mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
AK: Add LexicalPath::append and LexicalPath::join
This patch adds two new methods to LexicalPath. LexicalPath::append appends a new path component to a LexicalPath, and LexicalPath::join constructs a new LexicalPath from one or more components. Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
This commit is contained in:
parent
3f9927b0c3
commit
2de11b0dc8
2 changed files with 23 additions and 0 deletions
|
@ -116,4 +116,15 @@ String LexicalPath::relative_path(String absolute_path, const String& prefix)
|
|||
return absolute_path.substring(prefix_length);
|
||||
}
|
||||
|
||||
void LexicalPath::append(String const& component)
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_string);
|
||||
builder.append('/');
|
||||
builder.append(component);
|
||||
|
||||
m_string = builder.to_string();
|
||||
canonicalize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue