// Resolves any conflicts for the given output path. // Returns a non-conflicting output path. // May return the same value if there are no conflicts. // null means cancel. public string ResolveOutputPathConflicts(string initialOutputPath, HashSet <string> excludedPaths, bool isBatch) { HashSet <string> queuedFiles = excludedPaths; bool? conflict = Utilities.FileExists(initialOutputPath, queuedFiles); if (conflict == null) { return(initialOutputPath); } WhenFileExists preference; if (isBatch) { preference = CustomConfig.WhenFileExistsBatch; } else { preference = CustomConfig.WhenFileExists; } switch (preference) { case WhenFileExists.Prompt: break; case WhenFileExists.Overwrite: return(initialOutputPath); case WhenFileExists.AutoRename: return(Utilities.CreateUniqueFileName(initialOutputPath, queuedFiles)); default: throw new ArgumentOutOfRangeException(); } // Continue and prompt user for resolution var conflictDialog = new FileConflictDialogViewModel(initialOutputPath, (bool)conflict); WindowManager.OpenDialog(conflictDialog, this.main); switch (conflictDialog.FileConflictResolution) { case FileConflictResolution.Cancel: return(null); case FileConflictResolution.Overwrite: return(initialOutputPath); case FileConflictResolution.AutoRename: return(Utilities.CreateUniqueFileName(initialOutputPath, queuedFiles)); default: throw new ArgumentOutOfRangeException(); } }
// Resolves any conflicts for the given output path. // Returns a non-conflicting output path. // May return the same value if there are no conflicts. // null means cancel. public string ResolveOutputPathConflicts(string initialOutputPath, HashSet<string> excludedPaths, bool isBatch) { HashSet<string> queuedFiles = excludedPaths; bool? conflict = Utilities.FileExists(initialOutputPath, queuedFiles); if (conflict == null) { return initialOutputPath; } WhenFileExists preference; if (isBatch) { preference = CustomConfig.WhenFileExistsBatch; } else { preference = CustomConfig.WhenFileExists; } switch (preference) { case WhenFileExists.Prompt: break; case WhenFileExists.Overwrite: return initialOutputPath; case WhenFileExists.AutoRename: return Utilities.CreateUniqueFileName(initialOutputPath, queuedFiles); default: throw new ArgumentOutOfRangeException(); } // Continue and prompt user for resolution var conflictDialog = new FileConflictDialogViewModel(initialOutputPath, (bool)conflict); WindowManager.OpenDialog(conflictDialog, this.main); switch (conflictDialog.FileConflictResolution) { case FileConflictResolution.Cancel: return null; case FileConflictResolution.Overwrite: return initialOutputPath; case FileConflictResolution.AutoRename: return Utilities.CreateUniqueFileName(initialOutputPath, queuedFiles); default: throw new ArgumentOutOfRangeException(); } }