Recent

Author Topic: TFileStream file size limit  (Read 2848 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 3412
  • Compiler Developer
Re: TFileStream file size limit
« Reply #15 on: October 05, 2021, 01:32:03 pm »
In de context of 32 bit, Sarah. That's why I suggested it to express address space.

You don't mention 32-bit here anywhere except for the PE flag (and the other messages before yours hadn't mentioned 32-bit either):

AFAIK Address space is limited to high(qword), at lot.., but single read/writes are limited to high(nativeint) which is indeed 2G
Note that in practise it limits to available memrory otherwise a EOutOfMemory is thrown.
Note that for 32 bit WIN there is a PE flag - since windows 7 - that extends available memory to 4G but still with the limitation ffor single read/writes

lagprogramming

  • Full Member
  • ***
  • Posts: 170
Re: TFileStream file size limit
« Reply #16 on: October 17, 2021, 04:54:01 pm »
   I've stopped using the file related classes like TFileStream and went to a lower level: FileOpen, FileCreate, FileClose, FileSeek and so on.
   The following function returns a negative number when passing a 3GB file. The problem is at FileSeek.

Code: Pascal  [Select][+][-]
  1. Function GetFileSizeUsingFileSeek(FilePath:string):Int64;
  2. var
  3.   FileH:THandle;
  4. begin
  5.   FileH:=FileOpen(FilePath,fmOpenRead);
  6.   Result:=FileSeek(FileH,0,fsFromEnd);//Also FileSeek returns a wrong result for files greater than 2GB. In linux-x86_64 it may return negative values.
  7.   FileClose(FileH);
  8. end;

   In order to avoid such problems I've decided to modify the file format that is used by the application and avoid file related classes by using low level routines, which means that for me the problem will be solved soon. To be frank, I've never expected such a problem. Probably I'm one of the few who uses files so large in size. In the future I expect other developers to have the same problem.

Alextp

  • Hero Member
  • *****
  • Posts: 1416
    • UVviewsoft
Re: TFileStream file size limit
« Reply #17 on: October 17, 2021, 05:04:10 pm »
Quote
The following function returns a negative number when passing a 3GB file. The problem is at FileSeek.
Code: Pascal  [Select][+][-]
  1. Function FileSeek (Handle : THandle; FOffset, Origin: Longint) : Longint;
  2. Function FileSeek (Handle : THandle; FOffset: Int64; Origin: Longint) : Int64;
  3.  
your code calls 1st overload! so it returns nagative res.
try to call 2nd overload.

Result:=FileSeek(FileH,Int64(0),fsFromEnd);
« Last Edit: October 17, 2021, 05:06:46 pm by Alextp »

Thaddy

  • Hero Member
  • *****
  • Posts: 10929
Re: TFileStream file size limit
« Reply #18 on: October 17, 2021, 05:05:39 pm »
The problem is merely the declaration as a signed type instead of unsigned.
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

 

TinyPortal © 2005-2018