mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Added 'CopyToTarget' command
This commit is contained in:
parent
2ea5c34252
commit
2c630a5ba9
2 changed files with 68 additions and 10 deletions
|
@ -139,6 +139,23 @@ namespace System.IO
|
|||
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)
|
||||
{
|
||||
let searchStr = scope String();
|
||||
|
|
|
@ -1300,8 +1300,7 @@ namespace IDE
|
|||
gApp.mProjectPanel.[Friend]RemoveSelectedItems(false);
|
||||
}
|
||||
|
||||
[IDECommand]
|
||||
public void CopyToDependents(String srcPath)
|
||||
void DoCopyToTarget(String srcPath, bool onlyDependents)
|
||||
{
|
||||
let depProject = GetProject();
|
||||
if (depProject == null)
|
||||
|
@ -1312,7 +1311,8 @@ namespace IDE
|
|||
|
||||
for (let checkProject in gApp.mWorkspace.mProjects)
|
||||
{
|
||||
if (checkProject.HasDependency(depProject.mProjectName))
|
||||
if ((checkProject.HasDependency(depProject.mProjectName)) ||
|
||||
((checkProject == depProject) && (!onlyDependents)))
|
||||
{
|
||||
List<String> targetPaths = scope .();
|
||||
defer ClearAndDeleteItems(targetPaths);
|
||||
|
@ -1332,13 +1332,27 @@ namespace IDE
|
|||
String targetDirPath = scope .();
|
||||
Path.GetDirectoryPath(targetPaths[0], targetDirPath);
|
||||
|
||||
bool CopyFile(String srcPath)
|
||||
bool CopyFile(StringView srcPath, StringView destPath)
|
||||
{
|
||||
String fileName = scope .();
|
||||
Path.GetFileName(srcPath, fileName);
|
||||
if (Directory.Exists(srcPath))
|
||||
{
|
||||
if (Directory.CreateDirectory(destPath) case .Err)
|
||||
return false;
|
||||
|
||||
String destPath = scope .();
|
||||
Path.GetAbsolutePath(fileName, targetDirPath, destPath);
|
||||
for (let entry in Directory.Enumerate(srcPath))
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -1348,6 +1362,12 @@ namespace IDE
|
|||
return true;
|
||||
}
|
||||
|
||||
if ((srcPath.EndsWith('/')) || (srcPath.EndsWith('\\')))
|
||||
srcPath.RemoveFromEnd(1);
|
||||
|
||||
String fileName = scope .();
|
||||
Path.GetFileName(srcPath, fileName);
|
||||
|
||||
if (srcPath.Contains('*'))
|
||||
{
|
||||
String dirPath = scope .();
|
||||
|
@ -1359,13 +1379,22 @@ namespace IDE
|
|||
{
|
||||
String foundPath = scope .();
|
||||
entry.GetFilePath(foundPath);
|
||||
if (!CopyFile(foundPath))
|
||||
|
||||
String subDestPath = scope .();
|
||||
subDestPath.Append(targetDirPath);
|
||||
subDestPath.Append('/');
|
||||
entry.GetFileName(subDestPath);
|
||||
|
||||
if (!CopyFile(foundPath, subDestPath))
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CopyFile(srcPath))
|
||||
String destPath = scope .();
|
||||
Path.GetAbsolutePath(fileName, targetDirPath, destPath);
|
||||
|
||||
if (!CopyFile(srcPath, destPath))
|
||||
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]
|
||||
public void ExecuteRaw(String cmd)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue