File tree 1 file changed +41
-0
lines changed
WitcherScriptMerger/Forms
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -747,6 +747,47 @@ public void DeleteMerges(IEnumerable<TreeNode> fileNodes)
747
747
merge . RelativePath . EqualsIgnoreCase ( node . Text ) ) )
748
748
. ToList ( ) ;
749
749
DeleteMerges ( merges ) ;
750
+ if ( Program . Inventory . Merges . Count == 0 )
751
+ {
752
+ string gameDir = Program . Settings . Get ( "GameDirectory" ) ;
753
+ string mergeModPath = Path . Combine ( gameDir , "Mods" , Paths . RetrieveMergedModName ( ) ) ;
754
+ if ( ! Directory . Exists ( mergeModPath ) )
755
+ {
756
+ // Folder is gone - nothing to do here.
757
+ return ;
758
+ }
759
+
760
+ // KDiff must've created a backup which is why the mod folder still exists.
761
+ string [ ] filePaths = Directory . GetFiles ( mergeModPath , "*" , SearchOption . AllDirectories ) ;
762
+ string [ ] dirPaths = Directory . GetDirectories ( mergeModPath , "*" , SearchOption . AllDirectories )
763
+ . OrderByDescending ( dir => dir . Length ) . ToArray ( ) ;
764
+ string errorMsg = "Merges have been removed successfully, but we were unable to automatically "
765
+ + $ "remove the generated merged mod folder: { mergeModPath } ; please remove the folder manually.";
766
+ Array . ForEach ( filePaths , filePath =>
767
+ {
768
+ try
769
+ {
770
+ File . Delete ( filePath ) ;
771
+ } catch ( Exception exc )
772
+ {
773
+ ShowError ( errorMsg ) ;
774
+ return ;
775
+ }
776
+ } ) ;
777
+
778
+ Array . ForEach ( dirPaths , dirPath =>
779
+ {
780
+ try
781
+ {
782
+ Directory . Delete ( dirPath ) ;
783
+ }
784
+ catch ( Exception exc )
785
+ {
786
+ ShowError ( errorMsg ) ;
787
+ return ;
788
+ }
789
+ } ) ;
790
+ }
750
791
}
751
792
752
793
bool DeleteMerges ( List < Merge > merges )
You can’t perform that action at this time.
0 commit comments