1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24:10 +02:00

Added test for adding files during hotload

This commit is contained in:
Brian Fiete 2020-07-19 05:48:22 -07:00
parent c08d1161fb
commit 912fdbe195
6 changed files with 95 additions and 0 deletions

View file

@ -2558,5 +2558,42 @@ namespace IDE
valuePtr.Dispose();
*valuePtr = Variant.Create<String>(new String(value), true);
}
[IDECommand]
public void AddProjectItem(String projectName, String folderPath, String filePath)
{
var project = gApp.FindProjectByName(projectName);
if (project == null)
{
mScriptManager.Fail(scope String()..AppendF("Failed to find project '{}'", projectName));
return;
}
ProjectFolder foundFolder = null;
if (folderPath == "")
foundFolder = project.mRootFolder;
else
{
project.WithProjectItems(scope [&] (projectItem) =>
{
if (var projectFolder = projectItem as ProjectFolder)
{
var relDir = scope String();
projectFolder.GetRelDir(relDir);
if (Path.Equals(relDir, folderPath))
foundFolder = projectFolder;
}
});
}
if (foundFolder == null)
{
mScriptManager.Fail(scope String()..AppendF("Failed to find project folder '{}'", folderPath));
return;
}
IDEUtils.FixFilePath(filePath);
gApp.mProjectPanel.ImportFiles(foundFolder, scope .(filePath));
}
}
}