|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Diagnostics; |
3 | 4 | using System.IO;
|
4 | 5 | using System.Linq;
|
5 | 6 | using System.Net;
|
@@ -90,7 +91,9 @@ CommandOption maxConcurrency
|
90 | 91 | List<FileInfo> inputFiles;
|
91 | 92 | // If we're going to glob, we can't be fully rooted currently (fix me later)
|
92 | 93 |
|
93 |
| - if(inputFile.Value().Contains('*')) |
| 94 | + var isGlob = inputFile.Value().Contains('*'); |
| 95 | + |
| 96 | + if (isGlob) |
94 | 97 | {
|
95 | 98 | if(Path.IsPathRooted(inputFile.Value()))
|
96 | 99 | {
|
@@ -169,14 +172,25 @@ CommandOption maxConcurrency
|
169 | 172 | {
|
170 | 173 | FileInfo output;
|
171 | 174 |
|
| 175 | + var sw = Stopwatch.StartNew(); |
| 176 | + |
172 | 177 | // Special case if there's only one input file and the output has a value, treat it as a file
|
173 | 178 | if(inputFiles.Count == 1 && outputFile.HasValue())
|
174 |
| - { |
175 |
| - output = new FileInfo(ExpandFilePath(outputFile.Value())); |
| 179 | + { |
| 180 | + // See if it has a file extension and if not, treat as a directory and use the input file name |
| 181 | + var outFileValue = outputFile.Value(); |
| 182 | + if(Path.HasExtension(outFileValue)) |
| 183 | + { |
| 184 | + output = new FileInfo(ExpandFilePath(outputFile.Value())); |
| 185 | + } |
| 186 | + else |
| 187 | + { |
| 188 | + output = new FileInfo(Path.Combine(ExpandFilePath(outFileValue), inputFiles[0].Name)); |
| 189 | + } |
176 | 190 | }
|
177 | 191 | else
|
178 | 192 | {
|
179 |
| - // if the output is speciied, treat it as a directory, if not, overwrite the current file |
| 193 | + // if the output is specified, treat it as a directory, if not, overwrite the current file |
180 | 194 | if(!outputFile.HasValue())
|
181 | 195 | {
|
182 | 196 | output = new FileInfo(input.FullName);
|
@@ -226,7 +240,7 @@ CommandOption maxConcurrency
|
226 | 240 | using var fs = new FileStream(output.FullName, FileMode.Create);
|
227 | 241 | str.CopyTo(fs);
|
228 | 242 |
|
229 |
| - signCommandLineApplication.Out.WriteLine($"Successfully signed '{input.FullName}'"); |
| 243 | + signCommandLineApplication.Out.WriteLine($"Successfully signed '{output.FullName}' in {sw.ElapsedMilliseconds} ms"); |
230 | 244 | });
|
231 | 245 |
|
232 | 246 |
|
|
0 commit comments