File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -430,7 +430,14 @@ constructor TDSKImage.CreateFromStream(Stream: TStream);
430
430
if CompareBlock(DSKInfoBlock.DiskInfoBlock, ' MV - CPC' ) then
431
431
FileFormat := diStandardDSK;
432
432
if CompareBlock(DSKInfoBlock.DiskInfoBlock, ' EXTENDED CPC DSK File' ) then
433
+ FileFormat := diExtendedDSK
434
+ else
435
+ if CompareBlockInsensitive(DSKInfoBlock.DiskInfoBlock, ' EXTENDED CPC DSK FILE' ) then
436
+ begin
433
437
FileFormat := diExtendedDSK;
438
+ Corrupt := True;
439
+ Messages.Add(' File signature has incorrect case.' );
440
+ end ;
434
441
435
442
if FileFormat <> diInvalid then
436
443
begin
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ function StrBufPos(ByteArray: array of byte; SubString: string): integer;
33
33
34
34
function CompareBlock (A: array of char; B: string): boolean;
35
35
function CompareBlockStart (A: array of char; B: string; Start: integer): boolean;
36
+ function CompareBlockInsensitive (A: array of char; B: string): boolean;
36
37
37
38
function FontToDescription (ThisFont: TFont): string;
38
39
function FontFromDescription (Description: string): TFont;
@@ -84,9 +85,9 @@ function CompareBlock(A: array of char; B: string): boolean;
84
85
begin
85
86
Result := True;
86
87
Idx := 0 ;
87
- while ( Result and (Idx < Length(B) - 1 ) ) do
88
+ while Result and (Idx < Length(B) - 1 ) do
88
89
begin
89
- if ( A[Idx] <> B[Idx + 1 ]) then
90
+ if A[Idx] <> B[Idx + 1 ] then
90
91
Result := False;
91
92
Inc(Idx);
92
93
end ;
@@ -99,9 +100,27 @@ function CompareBlockStart(A: array of char; B: string; Start: integer): boolean
99
100
begin
100
101
Result := True;
101
102
Idx := 0 ;
102
- while ( Result and (Idx < Length(B) - 1 ) ) do
103
+ while Result and (Idx < Length(B) - 1 ) do
103
104
begin
104
- if (A[Idx + Start] <> B[Idx + 1 ]) then
105
+ if A[Idx + Start] <> B[Idx + 1 ] then
106
+ Result := False;
107
+ Inc(Idx);
108
+ end ;
109
+ end ;
110
+
111
+ // Compare two char arrays case insensitively
112
+ function CompareBlockInsensitive (A: array of char; B: string): boolean;
113
+ var
114
+ Idx: integer;
115
+ AChar, BChar: Char;
116
+ begin
117
+ Result := True;
118
+ Idx := 0 ;
119
+ while Result and (Idx < Length(B) - 1 ) do
120
+ begin
121
+ AChar := UpCase(A[Idx]);
122
+ BChar := UpCase(B[Idx + 1 ]);
123
+ if AChar <> BChar then
105
124
Result := False;
106
125
Inc(Idx);
107
126
end ;
You can’t perform that action at this time.
0 commit comments