mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
To be able to do this, we add a new class called CustodyBase, which can be resolved on-demand internally in the VirtualFileSystem resolving path code. When being resolved, CustodyBase will return a known custody if it was constructed with such, if that's not the case it will provide the root custody if the original path is absolute. Lastly, if that's not the case as well, it will resolve the given dirfd to provide a Custody object.
48 lines
757 B
C++
48 lines
757 B
C++
/*
|
|
* Copyright (c) 2024, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/StringView.h>
|
|
#include <Kernel/FileSystem/Custody.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class CustodyBase {
|
|
public:
|
|
CustodyBase(int dirfd, StringView path)
|
|
: m_path(path)
|
|
, m_dirfd(dirfd)
|
|
{
|
|
}
|
|
|
|
CustodyBase(NonnullRefPtr<Custody> base)
|
|
: m_base(base)
|
|
{
|
|
}
|
|
|
|
CustodyBase(Custody& base)
|
|
: m_base(base)
|
|
{
|
|
}
|
|
|
|
CustodyBase(Custody const& base)
|
|
: m_base(base)
|
|
{
|
|
}
|
|
|
|
ErrorOr<NonnullRefPtr<Custody>> resolve() const;
|
|
|
|
private:
|
|
RefPtr<Custody> const m_base;
|
|
StringView m_path;
|
|
int m_dirfd { -1 };
|
|
};
|
|
|
|
}
|