diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-06-09 11:40:29 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-14 22:08:22 +0200 |
| commit | fcc3e7cef934f9a1532d4e2f6f011d60d41574ce (patch) | |
| tree | 05797c7fe801691cf22e10c44a4d58d9743352a0 | |
| parent | c09ef501e1baf293d92b166e5e38e29a41cf64c2 (diff) | |
| download | kernel-fcc3e7cef934f9a1532d4e2f6f011d60d41574ce.tar.xz kernel-fcc3e7cef934f9a1532d4e2f6f011d60d41574ce.zip | |
fix split_into_path_and_filename logic, add todo
| -rw-r--r-- | kernel/kernel/filesystem/path.hpp | 7 | ||||
| -rw-r--r-- | kernel/kernel/filesystem/vfs.cpp | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/kernel/kernel/filesystem/path.hpp b/kernel/kernel/filesystem/path.hpp index c2d8e588..a0dbd1f1 100644 --- a/kernel/kernel/filesystem/path.hpp +++ b/kernel/kernel/filesystem/path.hpp @@ -79,9 +79,12 @@ namespace kernel::filesystem::path return {"", ""}; } - auto search_from = path.length() > 1 ? path.length() - 2 : 0; - auto last_separator_index = path.rfind('/', search_from); + if (path.length() > 1 && path.back() == '/') + { + path = path.substr(0, path.length() - 1); + } + auto last_separator_index = path.rfind('/'); if (last_separator_index == std::string_view::npos) { return {"", path}; diff --git a/kernel/kernel/filesystem/vfs.cpp b/kernel/kernel/filesystem/vfs.cpp index 2e4145db..4691dac3 100644 --- a/kernel/kernel/filesystem/vfs.cpp +++ b/kernel/kernel/filesystem/vfs.cpp @@ -189,6 +189,8 @@ namespace kernel::filesystem return kstd::failure(vfs_errc::invalid_path); } + // TODO check whether the target already exists + auto [parent_path, name] = path::split_into_path_and_filename(path); if (name.empty()) { |
