1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Added 'CopyToTarget' command

This commit is contained in:
Brian Fiete 2024-10-30 12:34:17 -04:00
parent 2ea5c34252
commit 2c630a5ba9
2 changed files with 68 additions and 10 deletions

View file

@ -139,6 +139,23 @@ namespace System.IO
return FileEnumerator(useStr, findFileData); return FileEnumerator(useStr, findFileData);
} }
public static FileEnumerator Enumerate(StringView dirPath)
{
let searchStr = scope String();
searchStr.Append(dirPath);
searchStr.Append("/*");
return Enumerate(searchStr, .Directories | .Files);
}
public static FileEnumerator Enumerate(StringView dirPath, StringView wildcard)
{
let searchStr = scope String();
searchStr.Append(dirPath);
searchStr.Append("/");
searchStr.Append(wildcard);
return Enumerate(searchStr, .Directories | .Files);
}
public static FileEnumerator EnumerateDirectories(StringView dirPath) public static FileEnumerator EnumerateDirectories(StringView dirPath)
{ {
let searchStr = scope String(); let searchStr = scope String();

View file

@ -1300,8 +1300,7 @@ namespace IDE
gApp.mProjectPanel.[Friend]RemoveSelectedItems(false); gApp.mProjectPanel.[Friend]RemoveSelectedItems(false);
} }
[IDECommand] void DoCopyToTarget(String srcPath, bool onlyDependents)
public void CopyToDependents(String srcPath)
{ {
let depProject = GetProject(); let depProject = GetProject();
if (depProject == null) if (depProject == null)
@ -1312,7 +1311,8 @@ namespace IDE
for (let checkProject in gApp.mWorkspace.mProjects) for (let checkProject in gApp.mWorkspace.mProjects)
{ {
if (checkProject.HasDependency(depProject.mProjectName)) if ((checkProject.HasDependency(depProject.mProjectName)) ||
((checkProject == depProject) && (!onlyDependents)))
{ {
List<String> targetPaths = scope .(); List<String> targetPaths = scope .();
defer ClearAndDeleteItems(targetPaths); defer ClearAndDeleteItems(targetPaths);
@ -1332,13 +1332,27 @@ namespace IDE
String targetDirPath = scope .(); String targetDirPath = scope .();
Path.GetDirectoryPath(targetPaths[0], targetDirPath); Path.GetDirectoryPath(targetPaths[0], targetDirPath);
bool CopyFile(String srcPath) bool CopyFile(StringView srcPath, StringView destPath)
{ {
String fileName = scope .(); if (Directory.Exists(srcPath))
Path.GetFileName(srcPath, fileName); {
if (Directory.CreateDirectory(destPath) case .Err)
return false;
String destPath = scope .(); for (let entry in Directory.Enumerate(srcPath))
Path.GetAbsolutePath(fileName, targetDirPath, destPath); {
String foundPath = scope .();
entry.GetFilePath(foundPath);
String subDestPath = scope .();
subDestPath.Append(destPath);
subDestPath.Append('/');
entry.GetFileName(subDestPath);
if (!CopyFile(foundPath, subDestPath))
return false;
}
return true;
}
if (File.CopyIfNewer(srcPath, destPath) case .Err) if (File.CopyIfNewer(srcPath, destPath) case .Err)
{ {
@ -1348,6 +1362,12 @@ namespace IDE
return true; return true;
} }
if ((srcPath.EndsWith('/')) || (srcPath.EndsWith('\\')))
srcPath.RemoveFromEnd(1);
String fileName = scope .();
Path.GetFileName(srcPath, fileName);
if (srcPath.Contains('*')) if (srcPath.Contains('*'))
{ {
String dirPath = scope .(); String dirPath = scope .();
@ -1359,13 +1379,22 @@ namespace IDE
{ {
String foundPath = scope .(); String foundPath = scope .();
entry.GetFilePath(foundPath); entry.GetFilePath(foundPath);
if (!CopyFile(foundPath))
String subDestPath = scope .();
subDestPath.Append(targetDirPath);
subDestPath.Append('/');
entry.GetFileName(subDestPath);
if (!CopyFile(foundPath, subDestPath))
return; return;
} }
} }
else else
{ {
if (!CopyFile(srcPath)) String destPath = scope .();
Path.GetAbsolutePath(fileName, targetDirPath, destPath);
if (!CopyFile(srcPath, destPath))
return; return;
} }
} }
@ -1373,6 +1402,18 @@ namespace IDE
} }
} }
[IDECommand]
public void CopyToDependents(String srcPath)
{
DoCopyToTarget(srcPath, true);
}
[IDECommand]
public void CopyToTarget(String srcPath)
{
DoCopyToTarget(srcPath, false);
}
[IDECommand] [IDECommand]
public void ExecuteRaw(String cmd) public void ExecuteRaw(String cmd)
{ {