@@ -60,49 +60,9 @@ function isopen end
6060Close an I/O stream. Performs a [`flush`](@ref) first.
6161"""
6262function close end
63-
64- """
65- shutdown(stream)
66-
67- Shutdown the write half of a full-duplex I/O stream. Performs a [`flush`](@ref)
68- first. Notify the other end that no more data will be written to the underlying
69- file. This is not supported by all IO types.
70-
71- # Examples
72- ```jldoctest
73- julia> io = Base.BufferStream(); # this never blocks, so we can read and write on the same Task
74-
75- julia> write(io, "request");
76-
77- julia> # calling `read(io)` here would block forever
78-
79- julia> shutdown(io);
80-
81- julia> read(io, String)
82- "request"
83- """
84- function shutdown end
85-
86- """
87- flush(stream)
88-
89- Commit all currently buffered writes to the given stream.
90- """
9163function flush end
92-
93- """
94- bytesavailable(io)
95-
96- Return the number of bytes available for reading before a read from this stream or buffer will block.
97-
98- # Examples
99- ```jldoctest
100- julia> io = IOBuffer("JuliaLang is a GitHub organization");
101-
102- julia> bytesavailable(io)
103- 34
104- ```
105- """
64+ function wait_readnb end
65+ function wait_close end
10666function bytesavailable end
10767
10868"""
@@ -121,7 +81,7 @@ function readavailable end
12181"""
12282 isreadable(io) -> Bool
12383
124- Return `false ` if the specified IO object is not readable.
84+ Return `true ` if the specified IO object is readable (if that can be determined) .
12585
12686# Examples
12787```jldoctest
@@ -139,12 +99,12 @@ true
13999julia> rm("myfile.txt")
140100```
141101"""
142- isreadable (io :: IO ) = isopen (io)
102+ function isreadable end
143103
144104"""
145105 iswritable(io) -> Bool
146106
147- Return `false ` if the specified IO object is not writable.
107+ Return `true ` if the specified IO object is writable (if that can be determined) .
148108
149109# Examples
150110```jldoctest
@@ -162,22 +122,9 @@ false
162122julia> rm("myfile.txt")
163123```
164124"""
165- iswritable (io:: IO ) = isopen (io)
166-
167- """
168- eof(stream) -> Bool
169-
170- Test whether an I/O stream is at end-of-file. If the stream is not yet exhausted, this
171- function will block to wait for more data if necessary, and then return `false`. Therefore
172- it is always safe to read one byte after seeing `eof` return `false`. `eof` will return
173- `false` as long as buffered data is still available, even if the remote end of a connection
174- is closed.
175- """
176- function eof end
177-
125+ function iswritable end
178126function copy end
179- function wait_readnb end
180- function wait_close end
127+ function eof end
181128
182129"""
183130 read(io::IO, T)
@@ -410,37 +357,65 @@ end
410357function pipe_reader end
411358function pipe_writer end
412359
413- for f in (:flush , :shutdown , :iswritable )
414- @eval $ (f)(io:: AbstractPipe ) = $ (f)(pipe_writer (io):: IO )
415- end
416360write (io:: AbstractPipe , byte:: UInt8 ) = write (pipe_writer (io):: IO , byte)
417361write (to:: IO , from:: AbstractPipe ) = write (to, pipe_reader (from))
418362unsafe_write (io:: AbstractPipe , p:: Ptr{UInt8} , nb:: UInt ) = unsafe_write (pipe_writer (io):: IO , p, nb):: Union{Int,UInt}
419363buffer_writes (io:: AbstractPipe , args... ) = buffer_writes (pipe_writer (io):: IO , args... )
364+ flush (io:: AbstractPipe ) = flush (pipe_writer (io):: IO )
420365
421- for f in (
422- # peek/mark interface
423- :mark , :unmark , :reset , :ismarked ,
424- # Simple reader functions
425- :read , :readavailable , :bytesavailable , :reseteof , :isreadable )
426- @eval $ (f)(io:: AbstractPipe ) = $ (f)(pipe_reader (io):: IO )
427- end
428366read (io:: AbstractPipe , byte:: Type{UInt8} ) = read (pipe_reader (io):: IO , byte):: UInt8
429367unsafe_read (io:: AbstractPipe , p:: Ptr{UInt8} , nb:: UInt ) = unsafe_read (pipe_reader (io):: IO , p, nb)
368+ read (io:: AbstractPipe ) = read (pipe_reader (io):: IO )
430369readuntil (io:: AbstractPipe , arg:: UInt8 ; kw... ) = readuntil (pipe_reader (io):: IO , arg; kw... )
431370readuntil (io:: AbstractPipe , arg:: AbstractChar ; kw... ) = readuntil (pipe_reader (io):: IO , arg; kw... )
432371readuntil (io:: AbstractPipe , arg:: AbstractString ; kw... ) = readuntil (pipe_reader (io):: IO , arg; kw... )
433372readuntil (io:: AbstractPipe , arg:: AbstractVector ; kw... ) = readuntil (pipe_reader (io):: IO , arg; kw... )
434373readuntil_vector! (io:: AbstractPipe , target:: AbstractVector , keep:: Bool , out) = readuntil_vector! (pipe_reader (io):: IO , target, keep, out)
435374readbytes! (io:: AbstractPipe , target:: AbstractVector{UInt8} , n= length (target)) = readbytes! (pipe_reader (io):: IO , target, n)
375+
376+ for f in (
377+ # peek/mark interface
378+ :mark , :unmark , :reset , :ismarked ,
379+ # Simple reader functions
380+ :readavailable , :isreadable )
381+ @eval $ (f)(io:: AbstractPipe ) = $ (f)(pipe_reader (io):: IO )
382+ end
436383peek (io:: AbstractPipe , :: Type{T} ) where {T} = peek (pipe_reader (io):: IO , T):: T
437- wait_readnb (io:: AbstractPipe , nb:: Int ) = wait_readnb (pipe_reader (io):: IO , nb)
438- eof (io:: AbstractPipe ) = eof (pipe_reader (io):: IO ):: Bool
439384
385+ iswritable (io:: AbstractPipe ) = iswritable (pipe_writer (io):: IO )
440386isopen (io:: AbstractPipe ) = isopen (pipe_writer (io):: IO ) || isopen (pipe_reader (io):: IO )
441387close (io:: AbstractPipe ) = (close (pipe_writer (io):: IO ); close (pipe_reader (io):: IO ))
388+ wait_readnb (io:: AbstractPipe , nb:: Int ) = wait_readnb (pipe_reader (io):: IO , nb)
442389wait_close (io:: AbstractPipe ) = (wait_close (pipe_writer (io):: IO ); wait_close (pipe_reader (io):: IO ))
443390
391+ """
392+ bytesavailable(io)
393+
394+ Return the number of bytes available for reading before a read from this stream or buffer will block.
395+
396+ # Examples
397+ ```jldoctest
398+ julia> io = IOBuffer("JuliaLang is a GitHub organization");
399+
400+ julia> bytesavailable(io)
401+ 34
402+ ```
403+ """
404+ bytesavailable (io:: AbstractPipe ) = bytesavailable (pipe_reader (io):: IO )
405+ bytesavailable (io:: DevNull ) = 0
406+
407+ """
408+ eof(stream) -> Bool
409+
410+ Test whether an I/O stream is at end-of-file. If the stream is not yet exhausted, this
411+ function will block to wait for more data if necessary, and then return `false`. Therefore
412+ it is always safe to read one byte after seeing `eof` return `false`. `eof` will return
413+ `false` as long as buffered data is still available, even if the remote end of a connection
414+ is closed.
415+ """
416+ eof (io:: AbstractPipe ) = eof (pipe_reader (io):: IO ):: Bool
417+ reseteof (io:: AbstractPipe ) = reseteof (pipe_reader (io):: IO )
418+
444419
445420# Exception-safe wrappers (io = open(); try f(io) finally close(io))
446421
@@ -1144,6 +1119,11 @@ ismarked(io::IO) = io.mark >= 0
11441119# Make sure all IO streams support flush, even if only as a no-op,
11451120# to make it easier to write generic I/O code.
11461121
1122+ """
1123+ flush(stream)
1124+
1125+ Commit all currently buffered writes to the given stream.
1126+ """
11471127flush (io:: IO ) = nothing
11481128
11491129"""
0 commit comments