public async Task Install(string file) { await ProcessUtilities.RunProcessAsync(file, "-passive"); }
/// <summary> /// Uses robocopy asynchronously to copy one directory tree to another /// </summary> /// <param name="sourceDirectory">Source directory (this is typically a DirectoryInfo not VFP since we don't control it)</param> /// <param name="targetDirectory">Directory node to where the source directory tree should be copied</param> /// <param name="cr">How to handle collisions</param> /// <param name="deleteSourceDirectory">Remove source directory</param> public static async Task CopyDirectoryTreeAsync ( string sourceDirPath, string targetDirPath, CollisionRemediation cr, Boolean deleteSourceDirectory = false) { Debug.Assert(sourceDirPath != null); Debug.Assert(targetDirPath != null); if (!Directory.Exists(sourceDirPath)) { throw new ScarabException("Source directory '{0}' does not exist", sourceDirPath); } string copyJob = string.Format ( "FileSync.CopyDirectoryTree2: {0} {1} {2} {3}", sourceDirPath, targetDirPath, cr.ToString(), deleteSourceDirectory ); Debug.WriteLine(copyJob); string switches = "/E "; // TODO Pri 2: /MT "; // Multi-threaded, copy full directory tree Boolean throwEx = false; switch (cr) { case CollisionRemediation.Break: case CollisionRemediation.Passive: case CollisionRemediation.FillIn: // TODO Pri 2: Figure out robocopy switches for these break; case CollisionRemediation.Mirror: switches = "/MIR "; break; case CollisionRemediation.Overwrite: break; case CollisionRemediation.Throw: throwEx = true; break; } if (Directory.Exists(targetDirPath) && throwEx) { throw new ScarabException("Target directory '{0}' already exists", targetDirPath); } if (deleteSourceDirectory) { switches += "/MOVE "; } string robocopyArgs = string.Format ( "\"{0}\" \"{1}\" {2}", sourceDirPath, targetDirPath, switches ); if (!File.Exists(Constants.ROBOCOPY_EXE_PATH)) { throw new ScarabException("Invalid robocopy path"); } for (Int32 k = 0; k <= 3; k++) { Int32 ret = await ProcessUtilities.RunProcessAsync ( Constants.ROBOCOPY_EXE_PATH, robocopyArgs ); // Int32 ret = ProcessUtilities.RunProcessWithWait( robocopyPath, robocopyArgs ); if (ret != 16) { Common.WriteLine("Robocopy result: {0}", CalculateRobocopyResult(ret)); Console.WriteLine("------------------------------------------------------------------------------"); break; } else if (k == 3) { throw new ScarabException("Fatal Robocopy Error on {0}", copyJob); } Common.DrawWarning("Robocopy result: {0}, retrying...", CalculateRobocopyResult(ret)); } }