Project.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "ProjectConfig.h"
  8. #include "ProjectFile.h"
  9. #include <AK/LexicalPath.h>
  10. #include <AK/Noncopyable.h>
  11. #include <AK/OwnPtr.h>
  12. #include <LibGUI/FileSystemModel.h>
  13. namespace HackStudio {
  14. class Project {
  15. AK_MAKE_NONCOPYABLE(Project);
  16. AK_MAKE_NONMOVABLE(Project);
  17. public:
  18. static OwnPtr<Project> open_with_root_path(ByteString const& root_path);
  19. GUI::FileSystemModel& model() { return *m_model; }
  20. const GUI::FileSystemModel& model() const { return *m_model; }
  21. ByteString name() const { return LexicalPath::basename(m_root_path); }
  22. ByteString root_path() const { return m_root_path; }
  23. NonnullRefPtr<ProjectFile> create_file(ByteString const& path) const;
  24. void for_each_text_file(Function<void(ProjectFile const&)>) const;
  25. ByteString to_absolute_path(ByteString const&) const;
  26. bool project_is_serenity() const;
  27. static constexpr auto config_file_path = ".hackstudio/config.json"sv;
  28. NonnullOwnPtr<ProjectConfig> config() const;
  29. private:
  30. explicit Project(ByteString const& root_path);
  31. RefPtr<GUI::FileSystemModel> m_model;
  32. ByteString m_root_path;
  33. };
  34. }