From cae20d2aa9a440e250b6928de3339ea4ee3c67b6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 Sep 2021 13:16:38 +0200 Subject: Kernel: Add FileDescription::try_serialize_absolute_path() Unlike FileDescription::absolute_path(), this knows that failures can happen and will propagate them to the caller. --- Kernel/FileSystem/FileDescription.cpp | 8 ++++++++ Kernel/FileSystem/FileDescription.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 6d29027a38..bd0bc23f6b 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -344,6 +344,14 @@ KResult FileDescription::close() return m_file->close(); } +KResultOr> FileDescription::try_serialize_absolute_path() +{ + if (m_custody) + return m_custody->try_serialize_absolute_path(); + // FIXME: Don't go through a String here! + return KString::try_create(m_file->absolute_path(*this)); +} + String FileDescription::absolute_path() const { if (m_custody) diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h index 3f1d67c93a..45b9db794b 100644 --- a/Kernel/FileSystem/FileDescription.h +++ b/Kernel/FileSystem/FileDescription.h @@ -64,6 +64,7 @@ public: KResultOr> read_entire_file(); + KResultOr> try_serialize_absolute_path(); String absolute_path() const; bool is_direct() const { return m_direct; } -- cgit v1.2.3