summaryrefslogtreecommitdiff
path: root/project.cpp
diff options
context:
space:
mode:
authorAlexander Khosrowshahi <alexk@vector35.com>2025-07-03 13:53:40 -0400
committerAlexander Khosrowshahi <alexk@vector35.com>2025-07-03 13:53:40 -0400
commit533b8e546a00537d6945f5329decab4b74a5bf09 (patch)
treefc4ee45f61ded3eeaf746f8828b2cc0373dd31a9 /project.cpp
parentdd5009bd17bc0d814c06d3a6962929084878f350 (diff)
Add get_files_by_path_in_project and get_path_in_project to C++ and python APIs
Diffstat (limited to 'project.cpp')
-rw-r--r--project.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/project.cpp b/project.cpp
index 6cb76a02..e795db61 100644
--- a/project.cpp
+++ b/project.cpp
@@ -477,7 +477,7 @@ Ref<ProjectFile> Project::GetFileById(const std::string& id) const
}
-Ref<ProjectFile> Project::GetFileByPathOnDisk(const std::string& path)
+Ref<ProjectFile> Project::GetFileByPathOnDisk(const std::string& path) const
{
BNProjectFile* file = BNProjectGetFileByPathOnDisk(m_object, path.c_str());
if (file == nullptr)
@@ -486,6 +486,25 @@ Ref<ProjectFile> Project::GetFileByPathOnDisk(const std::string& path)
}
+std::vector<Ref<ProjectFile>> Project::GetFilesByPathInProject(
+ const std::string& path
+) const
+{
+ size_t count;
+ BNProjectFile** files = BNProjectGetFilesByPathInProject(m_object, path.c_str(), &count);
+
+ std::vector<Ref<ProjectFile>> result;
+ result.reserve(count);
+ for (size_t i = 0; i < count; i++)
+ {
+ result.emplace_back(new ProjectFile(BNNewProjectFileReference(files[i])));
+ }
+
+ BNFreeProjectFileList(files, count);
+ return result;
+}
+
+
void Project::PushFile(Ref<ProjectFile> file)
{
BNProjectPushFile(m_object, file->m_object);