2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-10-21 13:46:55 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2022-03-18 19:17:22 -03:00
|
|
|
#include "ProjectConfig.h"
|
2019-11-01 14:40:32 -03:00
|
|
|
#include "ProjectFile.h"
|
2020-09-12 16:43:35 -03:00
|
|
|
#include <AK/LexicalPath.h>
|
2019-10-21 13:46:55 -03:00
|
|
|
#include <AK/Noncopyable.h>
|
|
|
|
|
#include <AK/OwnPtr.h>
|
2020-12-10 14:59:03 -03:00
|
|
|
#include <LibGUI/FileSystemModel.h>
|
2019-10-21 13:46:55 -03:00
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
namespace HackStudio {
|
|
|
|
|
|
2019-10-21 13:46:55 -03:00
|
|
|
class Project {
|
2020-08-26 16:52:24 -03:00
|
|
|
AK_MAKE_NONCOPYABLE(Project);
|
|
|
|
|
AK_MAKE_NONMOVABLE(Project);
|
|
|
|
|
|
2019-10-21 13:46:55 -03:00
|
|
|
public:
|
2022-04-01 14:58:27 -03:00
|
|
|
static OwnPtr<Project> open_with_root_path(String const& root_path);
|
2019-10-21 13:46:55 -03:00
|
|
|
|
2020-12-10 14:59:03 -03:00
|
|
|
GUI::FileSystemModel& model() { return *m_model; }
|
|
|
|
|
const GUI::FileSystemModel& model() const { return *m_model; }
|
2021-06-29 11:46:16 -03:00
|
|
|
String name() const { return LexicalPath::basename(m_root_path); }
|
2020-12-10 14:59:03 -03:00
|
|
|
String root_path() const { return m_root_path; }
|
2019-10-26 16:27:57 -03:00
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
NonnullRefPtr<ProjectFile> create_file(String const& path) const;
|
2019-10-27 15:39:15 -03:00
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
void for_each_text_file(Function<void(ProjectFile const&)>) const;
|
2021-11-19 11:13:07 -03:00
|
|
|
String to_absolute_path(String const&) const;
|
2022-01-07 11:27:13 -03:00
|
|
|
bool project_is_serenity() const;
|
2019-10-23 15:54:41 -03:00
|
|
|
|
2022-07-11 14:32:29 -03:00
|
|
|
static constexpr auto config_file_path = ".hackstudio/config.json"sv;
|
2022-03-18 19:17:22 -03:00
|
|
|
NonnullOwnPtr<ProjectConfig> config() const;
|
|
|
|
|
|
2019-10-21 13:46:55 -03:00
|
|
|
private:
|
2022-04-01 14:58:27 -03:00
|
|
|
explicit Project(String const& root_path);
|
2019-12-22 20:14:24 -03:00
|
|
|
|
2020-12-10 14:59:03 -03:00
|
|
|
RefPtr<GUI::FileSystemModel> m_model;
|
2019-12-22 20:14:24 -03:00
|
|
|
|
2020-12-10 14:59:03 -03:00
|
|
|
String m_root_path;
|
2019-10-21 13:46:55 -03:00
|
|
|
};
|
2020-08-17 10:22:30 -03:00
|
|
|
|
|
|
|
|
}
|