Parcourir la source

Supporting wildcard for CopyIfNewer

Brian Fiete il y a 6 ans
Parent
commit
243ffaf851
1 fichiers modifiés avec 33 ajouts et 8 suppressions
  1. 33 8
      IDE/src/ScriptManager.bf

+ 33 - 8
IDE/src/ScriptManager.bf

@@ -1188,9 +1188,6 @@ namespace IDE
 			{
 				if (checkProject.HasDependency(depProject.mProjectName))
 				{
-					String fileName = scope .();
-					Path.GetFileName(srcPath, fileName);
-
 					List<String> targetPaths = scope .();
 					defer ClearAndDeleteItems(targetPaths);
 
@@ -1203,13 +1200,41 @@ namespace IDE
 						String targetDirPath = scope .();
 						Path.GetDirectoryPath(targetPaths[0], targetDirPath);
 
-						String destPath = scope .();
-						Path.GetAbsolutePath(fileName, targetDirPath, destPath);
+						bool CopyFile(String srcPath)
+						{
+							String fileName = scope .();
+							Path.GetFileName(srcPath, fileName);
+
+							String destPath = scope .();
+							Path.GetAbsolutePath(fileName, targetDirPath, destPath);
+
+							if (File.CopyIfNewer(srcPath, destPath) case .Err)
+							{
+								mScriptManager.Fail("Failed to copy file '{}' to '{}'", srcPath, destPath);
+								return false;
+							}
+							return true;
+						}
 
-						if (File.CopyIfNewer(srcPath, destPath) case .Err)
+						if (srcPath.Contains('*'))
 						{
-							mScriptManager.Fail("Failed to copy file '{}' to '{}'", srcPath, destPath);
-							return;
+							String dirPath = scope .();
+							String wildcard = scope .();
+							Path.GetDirectoryPath(srcPath, dirPath);
+							Path.GetFileName(srcPath, wildcard);
+
+							for (let entry in Directory.EnumerateFiles(dirPath, wildcard))
+							{
+								String foundPath = scope .();
+								entry.GetFilePath(foundPath);
+								if (!CopyFile(foundPath))
+									return;
+							}
+						}
+						else
+						{
+							if (!CopyFile(srcPath))
+								return;
 						}
 					}
 				}