mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
Add a simple FileSystemPath class that can canonicalize paths.
Also a simple StringBuilder to help him out.
This commit is contained in:
parent
43475f248b
commit
88ad59bfb1
6 changed files with 102 additions and 6 deletions
|
@ -4,7 +4,7 @@ namespace AK {
|
|||
|
||||
void StringBuilder::append(String&& str)
|
||||
{
|
||||
m_strings.append(std::move(str));
|
||||
m_strings.append(move(str));
|
||||
}
|
||||
|
||||
void StringBuilder::append(char ch)
|
||||
|
@ -14,11 +14,25 @@ void StringBuilder::append(char ch)
|
|||
|
||||
String StringBuilder::build()
|
||||
{
|
||||
auto strings = std::move(m_strings);
|
||||
auto strings = move(m_strings);
|
||||
if (strings.isEmpty())
|
||||
return String::empty();
|
||||
|
||||
return String();
|
||||
size_t sizeNeeded = 1;
|
||||
for (auto& string : strings)
|
||||
sizeNeeded += string.length();
|
||||
|
||||
char* buffer;
|
||||
auto impl = StringImpl::createUninitialized(sizeNeeded, buffer);
|
||||
if (!impl)
|
||||
return String();
|
||||
|
||||
for (auto& string : strings) {
|
||||
memcpy(buffer, string.characters(), string.length());
|
||||
buffer += string.length();
|
||||
}
|
||||
*buffer = '\0';
|
||||
return String(move(impl));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue