-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSystemProcessor.cs
More file actions
52 lines (44 loc) · 1.6 KB
/
FileSystemProcessor.cs
File metadata and controls
52 lines (44 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace QuickAssemblyPublicizer;
public sealed class FileSystemProcessor
{
private readonly AssemblyPublicizer _assemblyPublicizer;
public FileSystemProcessor(AssemblyPublicizer assemblyPublicizer)
{
this._assemblyPublicizer = assemblyPublicizer;
}
public void Process(string inputPath, string outputPath)
{
if (File.Exists(inputPath))
{
ProcessSingleFile(inputPath, outputPath);
return;
}
if (Directory.Exists(inputPath))
{
ProcessDirectory(inputPath, outputPath);
return;
}
throw new FileNotFoundException($"Input path '{inputPath}' not found.");
}
private void ProcessSingleFile(string inputFilePath, string outputFilePath)
{
try
{
Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath) ?? outputFilePath);
_assemblyPublicizer.Publicize(inputFilePath, outputFilePath);
}
catch (Exception exception)
{
throw new InvalidOperationException($"Failed to process '{inputFilePath}': {exception.Message}", exception);
}
}
private void ProcessDirectory(string inputDirectoryPath, string outputDirectoryPath)
{
foreach (var filePath in Directory.EnumerateFiles(inputDirectoryPath, "*.dll", SearchOption.AllDirectories))
{
var relativePath = Path.GetRelativePath(inputDirectoryPath, filePath);
var outputFilePath = Path.Combine(outputDirectoryPath, relativePath);
ProcessSingleFile(filePath, outputFilePath);
}
}
}