2022-05-14 17:09:24 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
#include <AK/ByteString.h>
|
2022-05-14 17:09:24 +03:00
|
|
|
#include <AK/StringView.h>
|
|
|
|
|
|
|
|
|
|
namespace CodeComprehension {
|
|
|
|
|
|
|
|
|
|
class FileDB {
|
|
|
|
|
AK_MAKE_NONCOPYABLE(FileDB);
|
|
|
|
|
AK_MAKE_NONMOVABLE(FileDB);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual ~FileDB() = default;
|
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
virtual Optional<ByteString> get_or_read_from_filesystem(StringView filename) const = 0;
|
2023-10-10 15:00:58 +03:30
|
|
|
void set_project_root(StringView project_root)
|
|
|
|
|
{
|
|
|
|
|
if (project_root.is_null())
|
|
|
|
|
m_project_root.clear();
|
|
|
|
|
else
|
|
|
|
|
m_project_root = project_root;
|
|
|
|
|
}
|
2023-12-16 17:49:34 +03:30
|
|
|
Optional<ByteString> const& project_root() const { return m_project_root; }
|
|
|
|
|
ByteString to_absolute_path(StringView filename) const;
|
2022-05-14 17:09:24 +03:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
FileDB() = default;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-12-16 17:49:34 +03:30
|
|
|
Optional<ByteString> m_project_root;
|
2022-05-14 17:09:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|