mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 11:09:23 +02:00
amicommon: actually, not all filesystems (FTPMount, for example) support the ExamineFH method, so fall back to double-seek in that case
git-svn-id: trunk@31223 -
This commit is contained in:
parent
4e6f673a6d
commit
eb3bd4648c
@ -287,7 +287,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$DEFINE ASYS_FILESIZE_NO_DOUBLE_SEEK}
|
{$DEFINE ASYS_FILESIZE_USE_EXAMINEFH}
|
||||||
{ I changed the double-Seek filesize method which we
|
{ I changed the double-Seek filesize method which we
|
||||||
were using for 10+ years to the new ExamineFH() method.
|
were using for 10+ years to the new ExamineFH() method.
|
||||||
It should be available AmigaOS 2.0+, and much faster.
|
It should be available AmigaOS 2.0+, and much faster.
|
||||||
@ -298,10 +298,14 @@ end;
|
|||||||
It should be safe since there are several libc implementations
|
It should be safe since there are several libc implementations
|
||||||
using the same method on all Amiga flavors, but if anyone has
|
using the same method on all Amiga flavors, but if anyone has
|
||||||
a problem with it, disable this define to revert to the old
|
a problem with it, disable this define to revert to the old
|
||||||
method and report the issue. (KB) }
|
method and report the issue. (KB)
|
||||||
|
|
||||||
|
Actually, as some file systems (FTPMount, probably more) do
|
||||||
|
not support the ExamineFH action, lets fall back to double
|
||||||
|
seek silently in that case (KB) }
|
||||||
function do_filesize(handle : THandle) : longint;
|
function do_filesize(handle : THandle) : longint;
|
||||||
var
|
var
|
||||||
{$IFDEF ASYS_FILESIZE_NO_DOUBLE_SEEK}
|
{$IFDEF ASYS_FILESIZE_USE_EXAMINEFH}
|
||||||
fib: PFileInfoBlock;
|
fib: PFileInfoBlock;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
currfilepos: longint;
|
currfilepos: longint;
|
||||||
@ -310,18 +314,20 @@ begin
|
|||||||
do_filesize:=-1;
|
do_filesize:=-1;
|
||||||
if CheckInList(ASYS_fileList,handle)<>nil then begin
|
if CheckInList(ASYS_fileList,handle)<>nil then begin
|
||||||
|
|
||||||
{$IFDEF ASYS_FILESIZE_NO_DOUBLE_SEEK}
|
{$IFDEF ASYS_FILESIZE_USE_EXAMINEFH}
|
||||||
fib:=AllocDosObject(DOS_FIB,nil);
|
fib:=AllocDosObject(DOS_FIB,nil);
|
||||||
if fib <> nil then begin
|
if fib <> nil then begin
|
||||||
if ExamineFH(BPTR(handle), fib) then
|
if ExamineFH(BPTR(handle), fib) then
|
||||||
do_filesize:=fib^.fib_Size;
|
do_filesize:=fib^.fib_Size;
|
||||||
FreeDosObject(DOS_FIB,fib);
|
FreeDosObject(DOS_FIB,fib);
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
|
||||||
currfilepos:=do_filepos(handle);
|
|
||||||
do_filesize:=do_seekend(handle);
|
|
||||||
do_seek(handle,currfilepos);
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
if do_filesize = -1 then
|
||||||
|
begin
|
||||||
|
currfilepos:=do_filepos(handle);
|
||||||
|
do_filesize:=do_seekend(handle);
|
||||||
|
do_seek(handle,currfilepos);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user