[Lazarus] TFileStream

Dave Coventry dgcoventry at gmail.com
Wed Jan 7 15:01:27 CET 2009


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.brunner at gmail.com>:
> 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 <dgcoventry at gmail.com> wrote:
>> 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);
>> FS.ReadBuffer(fsbuffer,recsize);
>>
>> can I alter the array and then save the altered array back into the file?
>>
>> do I just write the entire array back?
>>
>> fsbuffer[128]:=56;
>> fsbuffer[132]:=42;
>> FS.WriteBuffer(fsbuffer,recsize);
>>
>>
>> or is there a better way?
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lazarus.freepascal.org
>> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>



More information about the Lazarus mailing list