@@ -280,47 +280,18 @@ public ExitCodes ExecuteFlashBinFiles(
280280
281281 Console . ForegroundColor = ConsoleColor . White ;
282282
283- return ExitCodes . OK ;
284- }
285-
286- private ExitCodes ProcessFilePaths ( IList < string > files , List < string > shadowFiles )
287- {
288- // J-Link can't handle diacritc chars
289- // developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved
290- foreach ( string binFile in files )
283+ // be nice and clean up shadow files
284+ try
291285 {
292- // make sure path is absolute
293- var binFilePath = Utilities . MakePathAbsolute (
294- Environment . CurrentDirectory ,
295- binFile ) ;
296-
297- // check file existence
298- if ( ! File . Exists ( binFilePath ) )
286+ foreach ( string shadowFile in shadowFiles )
299287 {
300- return ExitCodes . E5004 ;
301- }
302-
303- if ( ! binFilePath . IsNormalized ( NormalizationForm . FormD )
304- || binFilePath . Contains ( ' ' ) )
305- {
306- var tempFile = Path . Combine (
307- Environment . GetEnvironmentVariable ( "TEMP" , EnvironmentVariableTarget . Machine ) ,
308- Path . GetFileName ( binFilePath ) ) ;
309-
310- // copy file to shadow file
311- File . Copy (
312- binFilePath ,
313- tempFile ,
314- true ) ;
315-
316- shadowFiles . Add ( tempFile ) ;
317- }
318- else
319- {
320- // copy file to shadow list
321- shadowFiles . Add ( binFile ) ;
288+ File . Delete ( shadowFile ) ;
322289 }
323290 }
291+ catch ( Exception )
292+ {
293+ // ignore any exception here
294+ }
324295
325296 return ExitCodes . OK ;
326297 }
@@ -450,10 +421,23 @@ public ExitCodes ExecuteFlashHexFiles(
450421
451422 Console . ForegroundColor = ConsoleColor . White ;
452423
424+ // be nice and clean up shadow files
425+ try
426+ {
427+ foreach ( string shadowFile in shadowFiles )
428+ {
429+ File . Delete ( shadowFile ) ;
430+ }
431+ }
432+ catch ( Exception )
433+ {
434+ // ignore any exception here
435+ }
436+
453437 return ExitCodes . OK ;
454438 }
455439
456- public void ShowCLIOutput ( string cliOutput )
440+ internal void ShowCLIOutput ( string cliOutput )
457441 {
458442 // show CLI output, if verbosity is diagnostic
459443 if ( Verbosity == VerbosityLevel . Diagnostic )
@@ -536,5 +520,47 @@ internal static string RunJLinkCLI(string cmdFile, string arguments = null)
536520
537521 return jlinkCli . StandardOutput . ReadToEnd ( ) ;
538522 }
523+
524+ private ExitCodes ProcessFilePaths ( IList < string > files , List < string > shadowFiles )
525+ {
526+ // J-Link can't handle diacritc chars
527+ // developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved
528+ foreach ( string binFile in files )
529+ {
530+ // make sure path is absolute
531+ var binFilePath = Utilities . MakePathAbsolute (
532+ Environment . CurrentDirectory ,
533+ binFile ) ;
534+
535+ // check file existence
536+ if ( ! File . Exists ( binFilePath ) )
537+ {
538+ return ExitCodes . E5004 ;
539+ }
540+
541+ if ( ! binFilePath . IsNormalized ( NormalizationForm . FormD )
542+ || binFilePath . Contains ( ' ' ) )
543+ {
544+ var tempFile = Path . Combine (
545+ Environment . GetEnvironmentVariable ( "TEMP" , EnvironmentVariableTarget . Machine ) ,
546+ Path . GetFileName ( binFilePath ) ) ;
547+
548+ // copy file to shadow file
549+ File . Copy (
550+ binFilePath ,
551+ tempFile ,
552+ true ) ;
553+
554+ shadowFiles . Add ( tempFile ) ;
555+ }
556+ else
557+ {
558+ // copy file to shadow list
559+ shadowFiles . Add ( binFilePath ) ;
560+ }
561+ }
562+
563+ return ExitCodes . OK ;
564+ }
539565 }
540566}
0 commit comments