[fpc-pascal] TFileStream.SetSize sometimes fails
Michael Van Canneyt
michael at freepascal.org
Fri Aug 14 20:42:49 CEST 2009
On Fri, 14 Aug 2009, Martin wrote:
> Michael Van Canneyt wrote:
>> On Fri, 14 Aug 2009, Martin wrote:
>>>
>>> However in c I can specify
>>> open(fname, O_WRONLY | O_TRUNC );
>>> which does work (bypasses the bug)
>>>
>>> I haven't seen an equvivalent to O_TRUNC in fpc ?
>>
>> Sure there is:
>>
>> uses baseunix;
>>
>> Var
>> H : integer;
>>
>> begin
>> h:=fpOpen(fname,O_WrOnly or o_trunk)
>> end.
>>
>> But that is not relevant:
>> a) FPC itself should not work around kernel/vbox bugs.
>> b) It would not help in Mattias' case anyway...
> I never said FPC should workaround, and I am not in favour for the Lazarus to
> do so.
>
> Then again, if that had been a cross platform argument, there would be no
> reason (IMHO) why lazarus could not set the flag , when opening the file. If
> it had been cross-platform....
Windows has TRUNCATE_EXISTING, so in theory we could introduce fmTruncate to be
used in conjunction with fmOpenwrite, and then Mattias could use it in the TFileStream
constructor.
(As a side node: TRUNCATE_EXISTING also had/has bug when working on remote
files, you can find this in Microsofts Knowledge Base ;-))
Michael.
More information about the fpc-pascal
mailing list