summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-18 23:28:43 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-18 23:28:43 +0100
commitf5a0b6961c998e19c61e47c248c9e2355bd2040a (patch)
treeee7781e4cd815dbc1217d336404c23efe471f57e /AK
parentde4604ac95261fe95f5921b0d16ee65fb501332a (diff)
downloadserenity-f5a0b6961c998e19c61e47c248c9e2355bd2040a.zip
Fix mkdir with relative paths.
Diffstat (limited to 'AK')
-rw-r--r--AK/FileSystemPath.cpp27
-rw-r--r--AK/FileSystemPath.h2
2 files changed, 6 insertions, 23 deletions
diff --git a/AK/FileSystemPath.cpp b/AK/FileSystemPath.cpp
index fcba78420e..ba907e4c79 100644
--- a/AK/FileSystemPath.cpp
+++ b/AK/FileSystemPath.cpp
@@ -30,32 +30,17 @@ bool FileSystemPath::canonicalize(bool resolveSymbolicLinks)
canonicalParts.append(part);
}
if (canonicalParts.isEmpty()) {
- m_string = m_basename = m_dirname = "/";
+ m_string = m_basename = "/";
return true;
}
m_basename = canonicalParts.last();
-
- if (canonicalParts.size() == 1) {
- m_dirname = "/";
- } else {
- StringBuilder builder;
- for (size_t i = 0; i < canonicalParts.size() - 1; ++i) {
- auto& cpart = canonicalParts[i];
- builder.append('/');
- builder.append(cpart);
- }
- m_dirname = builder.build();
- }
-
- {
- StringBuilder builder;
- for (auto& cpart : canonicalParts) {
- builder.append('/');
- builder.append(move(cpart));
- }
- m_string = builder.build();
+ StringBuilder builder;
+ for (auto& cpart : canonicalParts) {
+ builder.append('/');
+ builder.append(move(cpart));
}
+ m_string = builder.build();
return true;
}
diff --git a/AK/FileSystemPath.h b/AK/FileSystemPath.h
index f53ec22d26..7a3623d0cc 100644
--- a/AK/FileSystemPath.h
+++ b/AK/FileSystemPath.h
@@ -13,13 +13,11 @@ public:
String string() const { return m_string; }
String basename() const { return m_basename; }
- String dirname() const { return m_dirname; }
private:
bool canonicalize(bool resolveSymbolicLinks = false);
String m_string;
- String m_dirname;
String m_basename;
bool m_isValid { false };
};