FIX: Bug [0001186] CRC-file not found due to case sensitivity error (and related stuff)

This commit is contained in:
Alexander Koblov 2015-10-02 20:16:20 +00:00
commit 1de768a372
2 changed files with 20 additions and 26 deletions

View file

@ -414,8 +414,14 @@ var
LineToParse: string;
UserAnswer: TFileSourceOperationUIResponse;
begin
result:=FALSE;
MaybeSummaryFilename:=SourceFiles[0].Path + SourceFiles[0].NameNoExt + ExtensionSeparator + 'CRC';
Result:= False;
//We just mimic TC who set in uppercase the "CRC" extension if the filename (without extension!) is made all with capital letters.
if SourceFiles[0].NameNoExt = UTF8UpperCase(SourceFiles[0].NameNoExt) then
MaybeSummaryFilename:= SourceFiles[0].Path + SourceFiles[0].NameNoExt + ExtensionSeparator + 'CRC'
else begin
MaybeSummaryFilename:= SourceFiles[0].Path + SourceFiles[0].NameNoExt + ExtensionSeparator + 'crc';
end;
//If CRC32 verification file is not found, try to ask user to make it available for us or maybe continue without it if it is what user want
UserAnswer:=fsourOk;
@ -426,23 +432,23 @@ begin
if mbFileExists(MaybeSummaryFilename) then
begin
hSummaryFile:=mbFileOpen(MaybeSummaryFilename, fmOpenRead);
hSummaryFile:= mbFileOpen(MaybeSummaryFilename, fmOpenRead);
try
while FileReadLn(hSummaryFile,LineToParse) do //"FileReadLn" return FALSE when we're at the end of the file! Wow! Let's use it for the loop control then!
while FileReadLn(hSummaryFile, LineToParse) do //"FileReadLn" return FALSE when we're at the end of the file! Wow! Let's use it for the loop control then!
begin
PosOfEqualSign := UTF8Pos('=',LineToParse);
PosOfEqualSign := UTF8Pos('=', LineToParse);
if PosOfEqualSign > 0 then //Investiguate *only* if the equal sign is present
begin
//Let's see if we could extract final filename.
//We first look for a UTF8 filename style. If so, take it, if not, search for the ANSI flavor
if UTF8Pos('filenameutf8=',UTF8LowerCase(LineToParse))>0 then
// Let's see if we could extract final filename.
// We first look for a UTF8 filename style. If so, take it, if not, search for the ANSI flavor
if UTF8Pos('filenameutf8=', UTF8LowerCase(LineToParse)) > 0 then
begin
TargetFile:=ExtractFilePath(TargetFile)+UTF8Copy(LineToParse,(PosOfEqualSign+1),(UTF8length(LineToParse)-PosOfEqualSign));
TargetFile:= ExtractFilePath(TargetFile) + UTF8Copy(LineToParse, (PosOfEqualSign + 1), MaxInt);
end
else
begin
if UTF8Pos('filename=',UTF8LowerCase(LineToParse))>0 then
TargetFile:=ExtractFilePath(TargetFile)+UTF8Copy(LineToParse,(PosOfEqualSign+1),(UTF8length(LineToParse)-PosOfEqualSign));
if Pos('filename=', LowerCase(LineToParse)) > 0 then
TargetFile:= ExtractFilePath(TargetFile) + AnsiToUtf8(Copy(LineToParse,(PosOfEqualSign + 1) ,MaxInt));
end;
//Let's see if we could extract final filesize...

View file

@ -76,21 +76,9 @@ end;
//In the ANSI filename, he puts "_" to replace any UTF8 needed character, not present in regular ANSI set.
//Let's do the same!
//
function ConvertStringToTCStringUTF8CharReplacedByUnderscore(sString: string): string;
var
indexChar:integer;
function ConvertStringToTCStringUTF8CharReplacedByUnderscore(const sString: string): string;
begin
result:='';
{$IFDEF DEBUG}
DCDebug(Format('UTF8length(sString): %d',[UTF8length(sString)]));
{$ENDIF}
for indexChar:=1 to UTF8length(sString) do
begin
{$IFDEF DEBUG}
DCDebug(UTF8copy(sString,indexChar,1));
{$ENDIF}
if UTF8copy(sString,indexChar,1)=UTF8ToAnsi(UTF8copy(sString,indexChar,1)) then result:=result+UTF8copy(sString,indexChar,1) else result:=result+'_';
end;
Result:= StringReplace(Utf8ToAnsi(sString), '?', '_', [rfReplaceAll]);
end;
procedure TFileSystemSplitOperation.Initialize;
@ -212,7 +200,7 @@ begin
if RequireACRC32VerificationFile then
begin
//We just mimic TC who set in uppercase the "CRC" extension if the filename (without extension!) is made all with capital letters.
if SourceFile.NameNoExt = UpperCase(SourceFile.NameNoExt) then
if SourceFile.NameNoExt = UTF8UpperCase(SourceFile.NameNoExt) then
SummaryFilename:= FTargetpath + SourceFile.NameNoExt + ExtensionSeparator + 'CRC'
else
SummaryFilename:= FTargetpath + SourceFile.NameNoExt + ExtensionSeparator + 'crc';