[fpc-pascal] Truncate procedure unable to work under Linux, is this a bug?
Géza Kovacs Géza
kg0231 at gmail.com
Sun May 17 18:07:05 CEST 2015
Truncate procedure unable to work under Linux, is this a bug?
This code is unable to work under linux: the Truncate drops an error
message if the file is larger than 2 or 3 GB.
I tested it with Free Pascal 2.6.4 under Debian Jessie 64 bit.
It produce the same error message under Ubuntu 12.04 32 bit with Free
Pascal 2.4.4
Sometimes I did not get any error message but the file (which was 2 or
3 GB) will be only some hundred MB after truncate...
It operates correctly under Windows.
It produce the following error message:
An unhandled exception occurred at $<address>:
EPrivilege : Privileged instruction
$<address>
Program File_Trunc;
{$MODE OBJFPC} {$H+}
uses dos,sysutils;
var
f : file of byte;
fs : int64;
begin
assign(f,paramstr(1));
ReSet(f);
fs := FileSize(f);
WriteLn('Original file size: ',fs);
fs := fs-3456789;
WriteLn('File size after truncate: ',fs);
Seek(f,fs);
Truncate(f);
Close(f);
end.
Best regards, Geza
More information about the fpc-pascal
mailing list