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

Michael Van Canneyt michael at freepascal.org
Sat Mar 9 20:54:33 CET 2019



On Sat, 9 Mar 2019, Anton Shepelev wrote:

> 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?

For these functions, you can get more info with GetLastOSError,
and use that to set InOutRes.

Michael.



More information about the fpc-devel mailing list