|
10 | 10 | using System.Linq; |
11 | 11 | using System.Runtime.InteropServices; |
12 | 12 | using System.Text; |
13 | | -using System.Threading; |
14 | 13 |
|
15 | 14 | namespace nanoFramework.Tools.FirmwareFlasher |
16 | 15 | { |
@@ -180,41 +179,33 @@ public ExitCodes ExecuteFlashBinFiles( |
180 | 179 | } |
181 | 180 | } |
182 | 181 |
|
| 182 | + List<string> shadowFiles = new List<string>(); |
| 183 | + |
183 | 184 | // J-Link can't handle diacritc chars |
184 | 185 | // developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved |
185 | 186 | foreach (string binFile in files) |
186 | 187 | { |
187 | | - if (!binFile.IsNormalized(NormalizationForm.FormD)) |
| 188 | + if (!binFile.IsNormalized(NormalizationForm.FormD) |
| 189 | + || binFile.Contains(' ')) |
188 | 190 | { |
189 | | - Console.ForegroundColor = ConsoleColor.Red; |
190 | | - |
191 | | - Console.WriteLine(""); |
192 | | - Console.WriteLine("********************************* WARNING *********************************"); |
193 | | - Console.WriteLine("Diacritic chars found in the path to a binary file!"); |
194 | | - Console.WriteLine("J-Link can't handle those, please use a path with plain simple ASCII chars."); |
195 | | - Console.WriteLine("***************************************************************************"); |
196 | | - Console.WriteLine(""); |
| 191 | + var tempFile = Path.Combine( |
| 192 | + Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.Machine), |
| 193 | + Path.GetFileName(binFile)); |
197 | 194 |
|
198 | | - Console.ForegroundColor = ConsoleColor.White; |
| 195 | + // copy file to shadow file |
| 196 | + File.Copy( |
| 197 | + binFile, |
| 198 | + tempFile, |
| 199 | + true); |
199 | 200 |
|
200 | | - return ExitCodes.E8003; |
| 201 | + shadowFiles.Add(tempFile); |
201 | 202 | } |
202 | | - |
203 | | - if (binFile.Contains(' ')) |
| 203 | + else |
204 | 204 | { |
205 | | - Console.ForegroundColor = ConsoleColor.Red; |
206 | | - |
207 | | - Console.WriteLine(""); |
208 | | - Console.WriteLine("************************* WARNING **************************"); |
209 | | - Console.WriteLine("Binary file path contains spaces!"); |
210 | | - Console.WriteLine("J-Link can't handle those, please use a path without spaces."); |
211 | | - Console.WriteLine("************************************************************"); |
212 | | - Console.WriteLine(""); |
213 | | - |
214 | | - Console.ForegroundColor = ConsoleColor.White; |
215 | | - |
216 | | - return ExitCodes.E8003; |
| 205 | + // copy file to shadow list |
| 206 | + shadowFiles.Add(binFile); |
217 | 207 | } |
| 208 | + |
218 | 209 | } |
219 | 210 |
|
220 | 211 | // erase flash |
@@ -244,7 +235,7 @@ public ExitCodes ExecuteFlashBinFiles( |
244 | 235 |
|
245 | 236 | // program BIN file(s) |
246 | 237 | int index = 0; |
247 | | - foreach (string binFile in files) |
| 238 | + foreach (string binFile in shadowFiles) |
248 | 239 | { |
249 | 240 | // make sure path is absolute |
250 | 241 | var binFilePath = Utilities.MakePathAbsolute( |
|
0 commit comments