@@ -659,18 +659,43 @@ public async Task DumpAsync(string output)
659659
660660 Log . Info ( $ "Reading { file . TargetFileName } ({ file . SizeInBytes . AsStorageUnit ( ) } )") ;
661661 CurrentFileNumber ++ ;
662- var convertedFilename = Path . DirectorySeparatorChar == '\\ ' ? file . TargetFileName : file . TargetFileName . Replace ( '\\ ' , Path . DirectorySeparatorChar ) ;
663- var inputFilename = Path . Combine ( InputDevicePath , convertedFilename ) ;
662+ var targetFilename = file . TargetFileName ;
664663
665- if ( ! File . Exists ( inputFilename ) )
664+ var trailingPeriod = targetFilename . EndsWith ( '.' ) ;
665+ var inputFilePath = Path . Combine ( InputDevicePath , targetFilename ) ;
666+ // BLES00932 Demon's Souls: trailing . is trimmed on both Windows and Linux
667+ if ( trailingPeriod && ! File . Exists ( inputFilePath ) )
668+ {
669+ Log . Warn ( $ "Potential mastering error in { targetFilename } ") ;
670+ targetFilename = targetFilename . TrimEnd ( '.' ) ;
671+ inputFilePath = Path . Combine ( InputDevicePath , targetFilename ) ;
672+ }
673+ // BLJS92001 Tsugime Ranko: trailing . is replaced with #ABCD in Windows, but is kept as . on Linux
674+ if ( trailingPeriod && OperatingSystem . IsWindows ( ) && ! File . Exists ( inputFilePath ) )
675+ {
676+ var inputDir = Path . GetDirectoryName ( inputFilePath ) ;
677+ var testNameBase = Path . GetFileName ( inputFilePath ) ;
678+ var options = new EnumerationOptions { IgnoreInaccessible = true , RecurseSubdirectories = false } ;
679+ var lst = Directory . GetFiles ( inputDir , testNameBase + "#*" , options ) ;
680+ if ( lst is [ var match ] )
681+ {
682+ Log . Warn ( $ "Using { match } as a match for { file . TargetFileName } ") ;
683+ inputFilePath = match ;
684+ }
685+ else
686+ {
687+ Log . Error ( $ "Found { lst . Length } potential matches for { file . TargetFileName } ") ;
688+ }
689+ }
690+ if ( ! File . Exists ( inputFilePath ) )
666691 {
667692 Log . Error ( $ "Missing { file . TargetFileName } ") ;
668693 BrokenFiles . Add ( ( file . TargetFileName , "missing" ) ) ;
669694 continue ;
670695 }
671696
672- var outputFilename = Path . Combine ( outputPathBase , convertedFilename ) ;
673- var fileDir = Path . GetDirectoryName ( outputFilename ) ;
697+ var outputFilePath = Path . Combine ( outputPathBase , targetFilename ) ;
698+ var fileDir = Path . GetDirectoryName ( outputFilePath ) ;
674699 if ( ! Directory . Exists ( fileDir ) )
675700 {
676701 Log . Debug ( "Creating directory " + fileDir ) ;
@@ -690,8 +715,8 @@ select v.Files[file.TargetFileName].Hashes
690715 try
691716 {
692717 tries -- ;
693- await using var outputStream = File . Open ( outputFilename , FileMode . Create , FileAccess . Write , FileShare . Read ) ;
694- await using var inputStream = File . Open ( inputFilename , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
718+ await using var outputStream = File . Open ( outputFilePath , FileMode . Create , FileAccess . Write , FileShare . Read ) ;
719+ await using var inputStream = File . Open ( inputFilePath , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
695720 await using var decrypter = new Decrypter ( inputStream , driveStream , decryptionKey , file . StartSector , sectorSize , unprotectedRegions ) ;
696721 Decrypter = decrypter ;
697722 await decrypter . CopyToAsync ( outputStream , 8 * 1024 * 1024 , Cts . Token ) . ConfigureAwait ( false ) ;
@@ -737,7 +762,7 @@ select v.Files[file.TargetFileName].Hashes
737762 await Task . Yield ( ) ;
738763 } while ( error && tries > 0 && ! Cts . IsCancellationRequested ) ;
739764
740- _ = new FileInfo ( outputFilename )
765+ _ = new FileInfo ( outputFilePath )
741766 {
742767 CreationTimeUtc = file . FileInfo . CreationTimeUtc ,
743768 LastWriteTimeUtc = file . FileInfo . LastWriteTimeUtc
@@ -774,7 +799,10 @@ select v.Files[file.TargetFileName].Hashes
774799 Log . Warn ( e , $ "Failed to fix timestamp for directory { dir . TargetDirName } ") ;
775800 }
776801 }
777- Log . Info ( "Completed" ) ;
802+ if ( BrokenFiles . Count is 0 )
803+ Log . Info ( "Completed" ) ;
804+ else
805+ Log . Warn ( $ "Completed with { BrokenFiles . Count } broken file{ ( BrokenFiles . Count == 1 ? "" : "s" ) } ") ;
778806 }
779807
780808 public static async Task < ( Version , GitHubReleaseInfo ) > CheckUpdatesAsync ( )
0 commit comments