New <file-r/w> word for opening a stream that can read and write to the same path -- only useful for *nix devices
parent
642964757a
commit
0cfe78aeaa
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2005 Slava Pestov.
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||||
! See http://factor.sf.net/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: io
|
IN: io
|
||||||
USE: io-internals
|
USING: io-internals kernel ;
|
||||||
|
|
||||||
: <file-reader> ( path -- stream ) open-read <reader> ;
|
: <file-reader> ( path -- stream ) open-read <reader> ;
|
||||||
: <file-writer> ( path -- stream ) open-write <writer> ;
|
: <file-writer> ( path -- stream ) open-write <writer> ;
|
||||||
|
: <file-r/w> ( path -- stream ) open-r/w dup <fd-stream> ;
|
||||||
|
|
|
@ -295,6 +295,7 @@ M: port stream-close ( stream -- )
|
||||||
] unless drop ;
|
] unless drop ;
|
||||||
|
|
||||||
! Make a duplex stream for reading/writing a pair of fds
|
! Make a duplex stream for reading/writing a pair of fds
|
||||||
|
: open-r/w ( path -- fd ) O_RDWR file-mode open dup io-error ;
|
||||||
|
|
||||||
: <fd-stream> ( infd outfd -- stream )
|
: <fd-stream> ( infd outfd -- stream )
|
||||||
>r <reader> r> <writer> <duplex-stream> ;
|
>r <reader> r> <writer> <duplex-stream> ;
|
||||||
|
|
Loading…
Reference in New Issue