File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -391,14 +391,16 @@ REBINT Mode_Syms[] = {
391
391
**
392
392
***********************************************************************/
393
393
{
394
- REBI64 len ; // maximum size
394
+ REBI64 len = 0 ; // maximum size
395
395
REBI64 cnt ;
396
396
// int what_if_it_changed;
397
397
398
398
// Compute and bound bytes remaining:
399
- len = file -> file .size - file -> file .index ; // already read
400
- if (len < 0 ) return 0 ;
401
- len &= MAX_READ_MASK ; // limit the size
399
+ if (file -> file .size > 0 ) {
400
+ len = file -> file .size - file -> file .index ; // already read
401
+ if (len < 0 ) return 0 ;
402
+ len &= MAX_READ_MASK ; // limit the size
403
+ }
402
404
403
405
// Return requested length:
404
406
if (!D_REF (arg )) return (REBCNT )len ;
Original file line number Diff line number Diff line change @@ -598,6 +598,15 @@ if exists? %/proc/cpuinfo [
598
598
not error? info: try [read /part %/proc/cpuinfo 10 ]
599
599
10 == length? info
600
600
]
601
+ ;; read a POSIX virtual file in chunks using an open port
602
+ --assert all [
603
+ port? port: try [open /read %/proc/cpuinfo ]
604
+ bin: make binary! 16000
605
+ while [not empty? tmp: read /part port 1024 ][append bin tmp]
606
+ equal? bin try [read %/proc/cpuinfo ]
607
+ port? try [close port]
608
+ not open? port
609
+ ]
601
610
]
602
611
--test-- "Reading an empty file"
603
612
--assert all [
You can’t perform that action at this time.
0 commit comments