Project.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "ProjectFile.h"
  8. #include <AK/LexicalPath.h>
  9. #include <AK/Noncopyable.h>
  10. #include <AK/OwnPtr.h>
  11. #include <LibGUI/FileSystemModel.h>
  12. namespace HackStudio {
  13. class Project {
  14. AK_MAKE_NONCOPYABLE(Project);
  15. AK_MAKE_NONMOVABLE(Project);
  16. public:
  17. static OwnPtr<Project> open_with_root_path(const String& root_path);
  18. GUI::FileSystemModel& model() { return *m_model; }
  19. const GUI::FileSystemModel& model() const { return *m_model; }
  20. String name() const { return LexicalPath::basename(m_root_path); }
  21. String root_path() const { return m_root_path; }
  22. NonnullRefPtr<ProjectFile> create_file(const String& path) const;
  23. void for_each_text_file(Function<void(const ProjectFile&)>) const;
  24. String to_absolute_path(String const&) const;
  25. private:
  26. explicit Project(const String& root_path);
  27. RefPtr<GUI::FileSystemModel> m_model;
  28. String m_root_path;
  29. };
  30. }