Re: [Lazarus] TFilestream raises exception class 'External SIGSEGV'

2009-04-14 Thread JoshyFun
Hello General, Tuesday, April 14, 2009, 3:16:13 PM, you wrote: DC Fstr:=TFileStream.Create('data',fmOpenRead); DC i:=0; DC while iFstr.Size do DC begin DC b:=Fstr.ReadByte; DC inc(i); DC. Stuff .. DC end; DC Fstr.Free; -- Exception raised

Re: [Lazarus] TFileStream

2009-01-29 Thread Dave Coventry
= snip === case ftype of 43://'+' begin FS:=TFileStream.Create(fname, fmshareDenyWrite); Try FS.Seek(pos,soFromBeginning); FS.ReadBuffer(fldheader[0],4); increm:=LEtoN(PLongInt(fldheader)^)+1; for m:=0 to 3

Re: [Lazarus] TFileStream

2009-01-29 Thread Michael Van Canneyt
On Thu, 29 Jan 2009, Dave Coventry wrote: = snip === case ftype of 43://'+' begin FS:=TFileStream.Create(fname, fmshareDenyWrite); Try FS.Seek(pos,soFromBeginning); FS.ReadBuffer(fldheader[0],4);

Re: [Lazarus] TFileStream

2009-01-29 Thread Paul Ishenin
Dave Coventry wrote: ... FS:=TFileStream.Create(fname, fmshareDenyWrite); ... I am trying to read a block of 4 bytes, increment it by one and write it back again. However, if fails on the write. Please read carefully what have you written: FS := TFileStream.Create(fname,

Re: [Lazarus] TFileStream

2009-01-27 Thread Dave Coventry
2009/1/27 Michael Van Canneyt mich...@freepascal.org: That is what he is saying, yes. I can confirm that this is the case. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
I'm having some difficulty over this: = snip === FS:=TFileStream.Create(fname, fmshareDenyWrite); Try FS.ReadBuffer(hdbuffer[0],32); Finally FreeAndNil(FS); end; RecSize:=LEtoN(PSmallInt(@hdbuffer[10])^); SetLength(recbuffer,RecSize);

Re: [Lazarus] TFileStream

2009-01-26 Thread ajv
Dear Dave Coventry, Probably the FileStream still exist in an other thread. Application.ProcessMessages might help. Better is it to open the stream on fname once an reposition the pointer repeatedly. Success. = I'm having some

Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
Hi AJ. I was under the impression that this: FS:=TFileStream.Create(fname, fmshareDenyWrite); Try FS.ReadBuffer(hdbuffer[0],32); Finally FreeAndNil(FS);- end; would free the File Pointer to be used again. Do you suggest that I use another variable when I do it the second time?

Re: [Lazarus] TFileStream

2009-01-26 Thread Michael Van Canneyt
On Mon, 26 Jan 2009, Dave Coventry wrote: Hi AJ. I was under the impression that this: FS:=TFileStream.Create(fname, fmshareDenyWrite); Try FS.ReadBuffer(hdbuffer[0],32); Finally FreeAndNil(FS);- end; would free the File Pointer to be used again. That is correct.

Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
Hi Michael. The file is accessed correctly the first time, but fails the second time. 2009/1/26 Michael Van Canneyt mich...@freepascal.org: This is so by default, unless you create threads yourself ? No, I didn't. More likely is simply the fact that the file cannot be locked. How can I

Re: [Lazarus] TFileStream

2009-01-26 Thread ajv
The application is one thread, the file handling is done by the operating system in an other thread. FreeAndNil releases indded the Class TFileStream but the OS can still have a capture on the file. This will not happen if you use one instance of an attached class throughout your application.

Re: [Lazarus] TFileStream

2009-01-26 Thread Hans-Peter Diettrich
Dave Coventry schrieb: FS:=TFileStream.Create(fname, fmshareDenyWrite); IMO you should also specify the requested access (fmCreate or fmOpen...), even if zero happens to mean fmOpenRead. Nonetheless it looks strange when the same file cannot be reopened later. Are you sure that fname is

Re: [Lazarus] TFileStream

2009-01-26 Thread Vincent Snijders
2009/1/26, Mattias Gaertner nc-gaert...@netcologne.de: On Mon, 26 Jan 2009 15:49:24 +0200 Dave Coventry dgcoven...@gmail.com wrote: I'm having some difficulty over this: = snip === FS:=TFileStream.Create(fname, fmshareDenyWrite); Try

Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
2009/1/26 Vincent Snijders vincent.snijd...@gmail.com: 2009/1/26, Mattias Gaertner nc-gaert...@netcologne.de: Maybe you mean FillChar(recbuffer^,RecSize,' '); ? Or FillChar(recbuffer[1],RecSize,' '); if it is a string or [0] if it is a dynarray. Thanks. I'll put that in. It seemed to

Re: [Lazarus] TFileStream

2009-01-26 Thread Andrew Brunner
Actually, I'm thinking you're creating a memory problem with using fillchar and passing the pointer to the dynarray instead of the element. Try using FillChar with the zero element again... The reason why the construction maybe failing is b/c a potential memory leak created by not using the zero

Re: [Lazarus] TFileStream

2009-01-26 Thread Dave Coventry
2009/1/26 Andrew Brunner andrew.t.brun...@gmail.com: Actually, I'm thinking you're creating a memory problem with using fillchar and passing the pointer to the dynarray instead of the element. Try using FillChar with the zero element again... The reason why the construction maybe failing is

Re: [Lazarus] TFileStream

2009-01-26 Thread Michael Van Canneyt
On Mon, 26 Jan 2009, Dave Coventry wrote: 2009/1/26 Andrew Brunner andrew.t.brun...@gmail.com: Actually, I'm thinking you're creating a memory problem with using fillchar and passing the pointer to the dynarray instead of the element. Try using FillChar with the zero element again...

Re: [Lazarus] TFileStream

2009-01-07 Thread Dave Coventry
How about if you wanted to change the contents of the start of a file? Does it work if you seek to the start of the file and write a couple of bytes, say, or do you have to rewrite the entire file? 2009/1/7 Andrew Brunner andrew.t.brun...@gmail.com: You could c write specific calls to write a

Re: [Lazarus] TFileStream

2009-01-07 Thread Bart
On 1/7/09, Dave Coventry dgcoven...@gmail.com wrote: How about if you wanted to change the contents of the start of a file? Does it work if you seek to the start of the file and write a couple of bytes, say, or do you have to rewrite the entire file? Yes it will work. You will overwrite the

[Lazarus] TFileStream

2009-01-06 Thread Dave Coventry
I've started using TFileStream since posting a query here, but I'd like to know a bit more about it. Is there somewhere that I can find information on how to use it? Specifically, if I load a file into an array as follows: FS:=TFileStream.Create(fname, fmshareDenyWrite);

Re: [Lazarus] TFileStream

2009-01-06 Thread Andrew Brunner
You could c write specific calls to write a byte or segment of contiguous bytes. FS.Seek(128,soFromBegining); FS.WriteBuffer(fsBuffer[128],1); FS.Seek(132,soFromBegining); FS.WriteBuffer(fsBuffer[132],1); On Tue, Jan 6, 2009 at 7:55 PM, Dave Coventry dgcoven...@gmail.com wrote: I've started