[fpc-devel] Publish some of FPC's internal cross-platform functionality

Anton Shepelev anton.txt at gmail.com
Sat Mar 9 20:47:32 CET 2019


Michael Van Canneyt to Anton Shepelev:

> > function do_read (h: longint; addr: pointer; len:
> > longint) : longint; function do_write(h: longint; addr:
> > pointer; len: longint) : longint;
>
> I also don't see why you need this.  You have this
> functionality available in a cross-platform manner in
> THandleStream, or the sysutils functions.

THandleStream is out of the question because I don't do OOP,
but the functions FileRead and FileWrite in SysUtils will
indeed suffice for most of my use cases, thanks.

I don't understand, however, how to employ them for my
current task of writing a TextRec driver for a custom file
handle.  The standard routines report errors by setting the
InOutRes variable from the OS-specific error code via OS-
specific translation function Errno2InoutRes, which is not
published, whereas FileRead and FileWrite return -1 on any
error.  What shall I assign to InOutRes when one of them
fails?  Maybe they should be extended to set InOutRes in
addition to returning -1?

Or is there already a way to initialise a Text variable with
a user-supplied THandle?

-- 
Please, do not forward replies to my e-mail.




More information about the fpc-devel mailing list