bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ⎕FIO Buffer limit is 5000 Bytes


From: Hans-Peter Sorge
Subject: Re: ⎕FIO Buffer limit is 5000 Bytes
Date: Fri, 30 Oct 2020 15:59:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

Hello Jürgen,

sorry - I missed the the second help line entry for ⎕FIO[6].
The dyadic form is sufficient for my case.

Thank you and Best Regards
Hans-Peter



Am 30.10.20 um 14:34 schrieb Dr. Jürgen Sauermann:
Hi,

As already pointed out by Kacper, ⎕FIO[6] is intended to be used
multiple times and every monadic call will give you 5000 bytes (or less
at the end of the file). Thr dyadic form lets you control the buffer size (instead of 5000). If tou set it to, say, 100 Giga then wou will most likely get the entire
file (or WS FULL if the file is that large),

There is also ⎕FIO[26] which reads an entire file, but I am not sure how it
works with popen()ed streams. All ⎕FIO functions try to work without
unnecessary copies of the file contents, that's why you need to specify
the buffer size beforehand.

Best Regards,
Jürgen


On 10/30/20 1:25 PM, Kacper Gutowski wrote:
On Thu, Oct 29, 2020 at 10:22:52PM +0100, Hans-Peter Sorge wrote:
the return size from ⎕FIO[24] / ⎕FIO[6] is limited to 5000B:
(...)
Should be: What ever it takes :-)

It's not limited to 5000B, it's just the default size and you can use any other with dyadic form.  ⎕FIO is fairly low-level and has very few convenience wrappers like ⎕FIO[26].  Perhaps one doing popen and reading the whole output like Perl's `` would be in order too, but it definitely shouldn't be what ⎕FIO[6] does.

You can relatively easily do something like this:

    ∇ bytes←read_to_eof fd ;buf
[1]   bytes←0⍴0
[2]  loop:
[3]  →(⎕FIO['feof'] fd)/0
[4]   buf←⎕FIO['fread'] fd
[5]  →(0≡buf)/loop
[6]   ⎕ES(1≠⍴⍴buf)/⎕FIO['strerror'] buf
[7]   bytes←bytes,buf
[8]  →loop
    ∇

(It could be a one-liner if API were designed a bit better, but it's still workable.)

-k






reply via email to

[Prev in Thread] Current Thread [Next in Thread]