@@ -42,26 +42,18 @@ public static void ExportCollection<T>(string? filename, string outputPath, IEnu
4242
4343 public static void ExportDuplications ( string baseFileName , string outputPath , List < DuplicationCode > duplications , CoreUtils . ExportFormat format )
4444 {
45- string ? directory = Path . GetDirectoryName ( outputPath ) ;
46- if ( ! string . IsNullOrEmpty ( directory ) )
47- {
48- Directory . CreateDirectory ( directory ) ;
49- }
45+ PrepareDirectoryForOutput ( outputPath ) ;
5046
5147 ExportCollection ( baseFileName , outputPath , duplications , format ) ;
5248 }
5349
5450 public static async Task ExportDependencies ( string baseFileName , string outputPath , List < DependencyRelation > dependencies , CoreUtils . ExportFormat format )
5551 {
56- string ? directory = Path . GetDirectoryName ( outputPath ) ;
57- if ( ! string . IsNullOrEmpty ( directory ) )
58- {
59- Directory . CreateDirectory ( directory ) ;
60- }
52+ PrepareDirectoryForOutput ( outputPath ) ;
6153 string filename = CoreUtils . GetExportFileNameWithExtension ( baseFileName , format ) ;
62-
6354
64- ExportCollection ( filename , outputPath , dependencies , format ) ;
55+
56+ ExportCollection ( filename , outputPath , dependencies , format ) ;
6557
6658 DotGraph graph = DependencyGraphGenerator . GenerateGraphOnly ( dependencies ) ;
6759
@@ -70,13 +62,10 @@ public static async Task ExportDependencies(string baseFileName,string outputPat
7062 await DependencyGraphGenerator . CompileGraphAndWriteToFile ( filename , outputPath , graph ) ;
7163 }
7264
65+
7366 public static void ExportMetrics ( string baseFilename , string outputPath , AnalysisResult analyzeMetrics , string solutionPath , CoreUtils . ExportFormat format )
7467 {
75- string ? directory = Path . GetDirectoryName ( outputPath ) ;
76- if ( ! string . IsNullOrEmpty ( directory ) )
77- {
78- Directory . CreateDirectory ( directory ) ;
79- }
68+ PrepareDirectoryForOutput ( outputPath ) ;
8069 string TOTAL = "Total" ;
8170 var filePath = CoreUtils . GetExportFileNameWithExtension ( baseFilename , format ) ;
8271
@@ -153,6 +142,14 @@ public static int GetFileDuplicationsCount(Dictionary<string, uint> duplicationC
153142
154143 return ( int ) duplicationCounts . GetValueOrDefault ( normalizedPath ) ;
155144 }
145+ private static void PrepareDirectoryForOutput ( string outputPath )
146+ {
147+ string ? directory = Path . GetDirectoryName ( outputPath ) ;
148+ if ( ! string . IsNullOrEmpty ( directory ) )
149+ {
150+ Directory . CreateDirectory ( directory ) ;
151+ }
152+ }
156153 }
157154
158155 public interface IExportStrategy
0 commit comments