Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Michael Van Canneyt
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 : in

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Martin
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_WrOnl

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Michael Van Canneyt
On Fri, 14 Aug 2009, Martin wrote: Michael Van Canneyt wrote: On Thu, 13 Aug 2009, Mattias Gaertner wrote: I want to replace the content of an existing file (keeping the type and rights). I used: fs := TFileStream.Create(Filename, fmOpenWrite or fmShareDenyNone); fs.Size := 0; fs.Write(

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Martin
Michael Van Canneyt wrote: On Thu, 13 Aug 2009, Mattias Gaertner wrote: I want to replace the content of an existing file (keeping the type and rights). I used: fs := TFileStream.Create(Filename, fmOpenWrite or fmShareDenyNone); fs.Size := 0; fs.Write(.); fs.Free; But it does not always wo

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread David W Noon
On Fri, 14 Aug 2009 09:19:40 +0200 (CEST), Michael Van Canneyt wrote about Re: [fpc-pascal] TFileStream.SetSize sometimes fails: > On Thu, 13 Aug 2009, Mattias Gaertner wrote: [snip] > > This will loose the access rights and type of the file. > > Why does that matter ? I don&

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Mattias Gaertner
On Fri, 14 Aug 2009 01:09:27 +0200 Luca Olivetti wrote: > En/na Mattias Gaertner ha escrit: > > > > > Yes. The code worked pretty well for years on many systems. But > > you know the story of the ext4 bug. I hope this is not something > > like that. > > It was not a bug, and if you're doing it

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread Michael Van Canneyt
On Thu, 13 Aug 2009, Mattias Gaertner wrote: On Thu, 13 Aug 2009 21:46:23 +0200 (CEST) Michael Van Canneyt wrote: On Thu, 13 Aug 2009, Mattias Gaertner wrote: I want to replace the content of an existing file (keeping the type and rights). I used: fs := TFileStream.Create(Filename, fm

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-13 Thread Luca Olivetti
En/na Mattias Gaertner ha escrit: Yes. The code worked pretty well for years on many systems. But you know the story of the ext4 bug. I hope this is not something like that. It was not a bug, and if you're doing it on ext4 (and probably xfs) it's possible that what you're seeing is a workaro

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-13 Thread Martin
Mattias Gaertner wrote: On Thu, 13 Aug 2009 21:46:23 +0200 (CEST) Michael Van Canneyt wrote: On Thu, 13 Aug 2009, Mattias Gaertner wrote: I want to replace the content of an existing file (keeping the type and rights). I used: fs := TFileStream.Create(Filename, fmOpenWrite or fmShareD

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-13 Thread Mattias Gaertner
On Thu, 13 Aug 2009 21:46:23 +0200 (CEST) Michael Van Canneyt wrote: > > > On Thu, 13 Aug 2009, Mattias Gaertner wrote: > > > > > I want to replace the content of an existing file (keeping the type > > and rights). I used: > > > > fs := TFileStream.Create(Filename, fmOpenWrite or fmShareDenyNo

Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-13 Thread Michael Van Canneyt
On Thu, 13 Aug 2009, Mattias Gaertner wrote: I want to replace the content of an existing file (keeping the type and rights). I used: fs := TFileStream.Create(Filename, fmOpenWrite or fmShareDenyNone); fs.Size := 0; fs.Write(.); fs.Free; But it does not always work. The line fs.Size doe