This repository has been archived by the owner on Jun 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FileAggregator.cs
56 lines (47 loc) · 2.01 KB
/
FileAggregator.cs
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
52
53
54
55
56
using System.Collections.Generic;
using System.IO;
namespace SupportTool
{
class FileAggregator
{
public string TempDir { get; private set; }
public List<AggregatedFile> AggregatedFiles { get; private set; } = new List<AggregatedFile>();
public FileAggregator(string tempDir)
{
this.TempDir = tempDir;
}
/// <summary>
/// Tell the aggregator to add a file that doesn't exist yet.
///
/// Example: adding foo.txt will return the full path where this file
/// can be created (e.g. tmp\foo.txt) and will add this file to be
/// copied.
///
/// It's up to the developer to ensure that the file exists afterwards,
/// as it will throw an exception otherwise on archiving.
/// </summary>
/// <param name="destinationFileName">Filename relative from the destination directory</param>
/// <returns>The destination file info</returns>
public FileInfo AddVirtualFile(string destinationFileName)
{
FileInfo tempFile = new FileInfo(Path.Combine(TempDir, destinationFileName));
AggregatedFiles.Add(new AggregatedFile(tempFile));
return tempFile;
}
/// <summary>
/// Tell the aggregator to add an existing file.
///
/// The destination file will be the name relative from the
/// destination directory.
/// </summary>
/// <param name="sourceFileName">The file to be aggregated</param>
/// <param name="destinationFileName">The relative filename it should get</param>
/// <returns>The destination file info</returns>
public FileInfo AddExistingFile(string sourceFileName, string destinationFileName)
{
FileInfo destinationFile = new FileInfo(Path.Combine(TempDir, destinationFileName));
AggregatedFiles.Add(new AggregatedFile(new FileInfo(sourceFileName), destinationFile));
return destinationFile;
}
}
}