Skip to content

Commit 28349b9

Browse files
silvioprogccy
authored andcommitted
Move literal strings to resources; Specifies file sharing that prevents other applications from writing to the file; Fix common warnings/hints.
1 parent d5e099a commit 28349b9

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

System.Zip2.pas

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ interface
3232
System.Generics.Collections,
3333
System.Classes;
3434

35+
resourcestring
36+
SZipInvalidExtraField = 'Invalid extra field';
37+
3538
type
3639
/// <summary> Zip Compression Method Enumeration </summary>
3740
TZipCompression = (
@@ -390,8 +393,10 @@ TZipFile = class
390393
/// <param name="ArchiveFileName">Path + Name of file in the arcive.</param>
391394
/// <param name="Compression">Compression mode.</param>
392395
/// <param name="AExternalAttributes">External attributes for this file.</param>
396+
{$WARN SYMBOL_PLATFORM OFF}
393397
procedure Add(Data: TStream; const ArchiveFileName: string; Compression: TZipCompression = zcDeflate;
394398
AExternalAttributes: TFileAttributes = []); overload;
399+
{$WARN SYMBOL_PLATFORM ON}
395400
/// <summary> Add a memory file to the ZIP file. Allows programmer to specify
396401
/// the Local and Central Header data for more flexibility on what gets written.
397402
/// Minimal vailidation is done on the Header parameters; speficying bad options
@@ -462,8 +467,9 @@ implementation
462467
System.RTLConsts,
463468
System.ZLib,
464469
System.Types
465-
{$ifdef MSWINDOWS}, Winapi.Windows{$endif}
466-
;
470+
{$IFDEF MSWINDOWS}
471+
, Winapi.Windows
472+
{$ENDIF};
467473

468474
function DateTimeToWinFileDate(DateTime: TDateTime): UInt32;
469475
var
@@ -623,15 +629,15 @@ constructor TZipExtraField.Create(const aRawData: TBytes);
623629
iHeadSize := SizeOf(HeaderID) + SizeOf(DataSize);
624630

625631
if Length(aRawData) < iHeadSize then
626-
raise EZipException.Create('Invalid Zip ExtraField');
632+
raise EZipException.CreateRes(@SZipInvalidExtraField);
627633

628634
Move(aRawData[0], Self, iHeadSize);
629635

630636
SetLength(Data, Length(aRawData) - iHeadSize);
631637
Move(aRawData[iHeadSize], Data[0], Length(Data));
632638

633639
if DataSize <> Length(Data) then
634-
raise EZipException.Create('Invalid Zip ExtraField');
640+
raise EZipException.CreateRes(@SZipInvalidExtraField);
635641
end;
636642

637643
class operator TZipExtraField.Implicit(const A: TZipExtraField): TBytes;
@@ -1672,6 +1678,8 @@ procedure TZipFile.Read(const FileName: string; out Bytes: TBytes);
16721678
Read(IndexOf(FileName), Bytes);
16731679
end;
16741680

1681+
{$HINTS OFF}
1682+
16751683
procedure TZipFile.Read(Index: Integer; out Bytes: TBytes);
16761684
var
16771685
LStream: TStream;
@@ -1705,6 +1713,9 @@ procedure TZipFile.Read(Index: Integer; out Bytes: TBytes);
17051713
LStream.Free;
17061714
end;
17071715
end;
1716+
1717+
{$HINTS ON}
1718+
17081719
//{$ENDIF}
17091720

17101721
procedure TZipFile.Read(const FileName: string; out Stream: TStream; out LocalHeader: TZipHeader);
@@ -1952,6 +1963,8 @@ procedure TZipFile.Add(Data: TBytes; const ArchiveFileName: string;
19521963
end;
19531964
end;
19541965

1966+
{$WARN SYMBOL_PLATFORM OFF}
1967+
19551968
procedure TZipFile.Add(Data: TStream; const ArchiveFileName: string;
19561969
Compression: TZipCompression; AExternalAttributes: TFileAttributes);
19571970
var
@@ -1989,6 +2002,7 @@ procedure TZipFile.Add(Data: TStream; const ArchiveFileName: string;
19892002
Add(Data, LHeader);
19902003
end;
19912004

2005+
{$WARN SYMBOL_PLATFORM ON}
19922006

19932007
function TZipFile.IndexOf(const FileName: string): Integer;
19942008
var

0 commit comments

Comments
 (0)