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
|
|
|
|
|
|
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:
|
2020-12-10 14:59:03 -03:00
|
|
|
static OwnPtr<Project> open_with_root_path(const String& 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
|
|
|
|
2021-09-08 15:36:34 -03:00
|
|
|
NonnullRefPtr<ProjectFile> create_file(const String& path) const;
|
2019-10-27 15:39:15 -03:00
|
|
|
|
2020-12-10 14:59:03 -03:00
|
|
|
void for_each_text_file(Function<void(const ProjectFile&)>) const;
|
2019-10-23 15:54:41 -03:00
|
|
|
|
2019-10-21 13:46:55 -03:00
|
|
|
private:
|
2020-12-10 14:59:03 -03:00
|
|
|
explicit Project(const String& root_path);
|
2019-12-22 20:14:24 -03:00
|
|
|
|
2021-03-05 11:42:32 -03:00
|
|
|
String to_absolute_path(const String&) const;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
}
|