소스 검색

Change TFile.Size to Int64.

Jordan Russell 1 개월 전
부모
커밋
1663d225c0

+ 1 - 1
Projects/SetupLdr.dpr

@@ -396,7 +396,7 @@ begin
         programs that search for the offset table by ID. } 
       if (OffsetTable.Version <> SetupLdrOffsetTableVersion) or
          (GetCRC32(OffsetTable^, SizeOf(OffsetTable^) - SizeOf(OffsetTable.TableCRC)) <> OffsetTable.TableCRC) or
-         ((SourceF.Size.Hi = 0) and (SourceF.Size.Lo < OffsetTable.TotalSize)) then
+         (SourceF.Size < OffsetTable.TotalSize) then
         SetupCorruptError;
 
       SourceF.Seek(OffsetTable.Offset0);

+ 1 - 1
Projects/Src/Compiler.CompressionHandler.pas

@@ -99,7 +99,7 @@ var
 begin
   if Assigned(FDestFile) then begin
     if FDestFileIsDiskSlice then begin
-      DiskSliceHeader.TotalSize := FDestFile.Size.Lo;
+      DiskSliceHeader.TotalSize := FDestFile.Size;
       FDestFile.Seek(SizeOf(DiskSliceID));
       FDestFile.WriteBuffer(DiskSliceHeader, SizeOf(DiskSliceHeader));
     end;

+ 5 - 5
Projects/Src/Compiler.SetupCompiler.pas

@@ -2238,7 +2238,7 @@ begin
   try
     F := TFile.Create(Filename, fdOpenExisting, faRead, fsRead);
     try
-      Size := F.Size.Lo;
+      Size := F.CappedSize;
       SetLength(S, Size);
       F.ReadBuffer(S[1], Size);
 
@@ -8251,8 +8251,8 @@ begin
         if not UseSetupLdr then begin
           SetupFile := TFile.Create(ExeFilename, fdCreateAlways, faWrite, fsNone);
           try
-            SetupFile.WriteBuffer(SetupE32.Memory^, SetupE32.Size.Lo);
-            SizeOfExe := SetupFile.Size.Lo;
+            SetupFile.WriteBuffer(SetupE32.Memory^, SetupE32.CappedSize);
+            SizeOfExe := SetupFile.Size;
           finally
             SetupFile.Free;
           end;
@@ -8292,7 +8292,7 @@ begin
           SetupFile := TFile.Create(ExeFilename, fdOpenExisting, faReadWrite, fsNone);
           try
             UpdateSetupPEHeaderFields(SetupFile, TerminalServicesAware, DEPCompatible, ASLRCompatible);
-            SizeOfExe := SetupFile.Size.Lo;
+            SizeOfExe := SetupFile.Size;
           finally
             SetupFile.Free;
           end;
@@ -8317,7 +8317,7 @@ begin
             SetupLdrOffsetTable.OffsetEXE := ExeFile.Position.Lo;
             CompressSetupE32(SetupE32, ExeFile, SetupLdrOffsetTable.UncompressedSizeEXE,
               SetupLdrOffsetTable.CRCEXE);
-            SetupLdrOffsetTable.TotalSize := ExeFile.Size.Lo;
+            SetupLdrOffsetTable.TotalSize := ExeFile.Size;
             if DiskSpanning then begin
               SetupLdrOffsetTable.Offset1 := 0;
               { Compress the files in Setup-*.bin after we know the size of

+ 1 - 1
Projects/Src/Setup.FileExtractor.pas

@@ -163,7 +163,7 @@ begin
       SourceIsCorrupted('Invalid slice header (2)');
     if FSourceF.Read(DiskSliceHeader, SizeOf(DiskSliceHeader)) <> SizeOf(DiskSliceHeader) then
       SourceIsCorrupted('Invalid slice header (3)');
-    if FSourceF.Size.Lo <> DiskSliceHeader.TotalSize then
+    if FSourceF.Size <> DiskSliceHeader.TotalSize then
       SourceIsCorrupted('Invalid slice header (4)');
   end;
   FOpenedSlice := ASlice;

+ 1 - 1
Projects/Src/Setup.InstFunc.pas

@@ -829,7 +829,7 @@ begin
   F := TFile.Create(Filename, fdOpenExisting, faReadWrite, fsNone);
   try
     { Is it a valid .pif file? }
-    if F.Size.Lo >= $171 then begin
+    if F.Size >= $171 then begin
       F.Seek($63);
       F.ReadBuffer(B, SizeOf(B));
       { Toggle the "Close on exit" bit }

+ 1 - 2
Projects/Src/Setup.ScriptFunc.pas

@@ -1274,8 +1274,7 @@ var
       try
         var F := TFileRedir.Create(ScriptFuncDisableFsRedir, Stack.GetString(PStart-1), fdOpenExisting, faRead, fsReadWrite);
         try
-          var TmpFileSize := F.Size; { Make sure we access F.Size only once }
-          Stack.SetInt64(PStart-2, Int64(TmpFileSize.Hi) shl 32 + TmpFileSize.Lo);
+          Stack.SetInt64(PStart-2, F.Size);
           Stack.SetBool(PStart, True);
         finally
           F.Free;

+ 1 - 1
Projects/Src/Setup.Uninstall.pas

@@ -750,7 +750,7 @@ begin
     { Initialize messages }
     F := TFile.Create(UninstExeFilename, fdOpenExisting, faRead, fsRead);
     try
-      F.Seek(F.Size.Lo - SizeOf(UninstallerMsgTail));
+      F.Seek(F.Size - SizeOf(UninstallerMsgTail));
       F.ReadBuffer(UninstallerMsgTail, SizeOf(UninstallerMsgTail));
       if UninstallerMsgTail.ID <> UninstallerMsgTailID then begin
         { No valid UninstallerMsgTail record found at the end of the EXE;

+ 7 - 8
Projects/Src/Shared.FileClass.pas

@@ -29,7 +29,7 @@ type
     function GetCappedSize: Cardinal;
   protected
     function GetPosition: Integer64; virtual; abstract;
-    function GetSize: Integer64; virtual; abstract;
+    function GetSize: Int64; virtual; abstract;
   public
     class procedure RaiseError(ErrorCode: DWORD);
     class procedure RaiseLastError;
@@ -41,7 +41,7 @@ type
     procedure WriteBuffer(const Buffer; Count: Cardinal); virtual; abstract;
     property CappedSize: Cardinal read GetCappedSize;
     property Position: Integer64 read GetPosition;
-    property Size: Integer64 read GetSize;
+    property Size: Int64 read GetSize;
   end;
 
   TFile = class(TCustomFile)
@@ -53,7 +53,7 @@ type
       ACreateDisposition: TFileCreateDisposition; AAccess: TFileAccess;
       ASharing: TFileSharing): THandle; virtual;
     function GetPosition: Integer64; override;
-    function GetSize: Integer64; override;
+    function GetSize: Int64; override;
   public
     constructor Create(const AFilename: String;
       ACreateDisposition: TFileCreateDisposition; AAccess: TFileAccess;
@@ -77,7 +77,7 @@ type
   protected
     procedure AllocMemory(const ASize: Cardinal);
     function GetPosition: Integer64; override;
-    function GetSize: Integer64; override;
+    function GetSize: Int64; override;
   public
     constructor Create(const AFilename: String);
     constructor CreateFromMemory(const ASource; const ASize: Cardinal);
@@ -258,10 +258,9 @@ begin
   Result := LPosition;
 end;
 
-function TFile.GetSize: Integer64;
+function TFile.GetSize: Int64;
 begin
-  Result.Lo := GetFileSize(FHandle, @Result.Hi);
-  if (Result.Lo = INVALID_FILE_SIZE) and (GetLastError <> 0) then
+  if not GetFileSizeEx(FHandle, Result) then
     RaiseLastError;
 end;
 
@@ -373,7 +372,7 @@ begin
   Result := FPosition;
 end;
 
-function TMemoryFile.GetSize: Integer64;
+function TMemoryFile.GetSize: Int64;
 begin
   Result := FSize;
 end;