Kernel: Add FileDescription::try_serialize_absolute_path()

Unlike FileDescription::absolute_path(), this knows that failures can
happen and will propagate them to the caller.
This commit is contained in:
Andreas Kling 2021-09-07 13:16:38 +02:00
parent a27c6f5226
commit cae20d2aa9
Notes: sideshowbarker 2024-07-18 04:31:57 +09:00
2 changed files with 9 additions and 0 deletions

View file

@ -344,6 +344,14 @@ KResult FileDescription::close()
return m_file->close();
}
KResultOr<NonnullOwnPtr<KString>> 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)

View file

@ -64,6 +64,7 @@ public:
KResultOr<NonnullOwnPtr<KBuffer>> read_entire_file();
KResultOr<NonnullOwnPtr<KString>> try_serialize_absolute_path();
String absolute_path() const;
bool is_direct() const { return m_direct; }