File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 7272#=
7373NOTE: We need to define multiple methods because of ambiguity error with base IO methods.
7474=#
75- function Base. write (buffer:: FileBuffer , x:: Union{UInt8, Vector{UInt8} } )
75+ function Base. write (buffer:: FileBuffer , x:: Vector{UInt8} )
7676 iswritable (buffer) || throw (ArgumentError (" write failed, FileBuffer is not writeable" ))
7777 write (buffer. io, x)
7878end
@@ -82,6 +82,11 @@ function Base.write(buffer::FileBuffer, x::String)
8282 write (buffer. io, x)
8383end
8484
85+ function Base. write (buffer:: FileBuffer , x:: UInt8 )
86+ iswritable (buffer) || throw (ArgumentError (" write failed, FileBuffer is not writeable" ))
87+ write (buffer. io, x)
88+ end
89+
8590function Base. flush (buffer:: FileBuffer )
8691 if iswritable (buffer)
8792 seekstart (buffer)
Original file line number Diff line number Diff line change @@ -14,7 +14,12 @@ using FilePathsBase: FileBuffer
1414 @test ! eof (io)
1515 @test read (p, String) == read (io, String)
1616 @test eof (io)
17- seekstart (io)
17+ finally
18+ close (io)
19+ end
20+
21+ io = FileBuffer (p)
22+ try
1823 for b in read (p)
1924 @test read (io, UInt8) == b
2025 end
@@ -50,6 +55,23 @@ using FilePathsBase: FileBuffer
5055 finally
5156 close (io)
5257 end
58+
59+ rm (p2)
60+
61+ io = FileBuffer (p2; read= true ,write= true )
62+ try
63+ write (io, read (p1))
64+ flush (io)
65+
66+ seekstart (io)
67+ for b in read (p1)
68+ write (io, b)
69+ end
70+ flush (io)
71+ @test read (p1) == read (p2)
72+ finally
73+ close (io)
74+ end
5375 end
5476 end
5577 end
Original file line number Diff line number Diff line change @@ -384,7 +384,6 @@ ps = PathSet(; symlink=true)
384384 @test ispath (" cpstr" )
385385
386386 # Recursive directory
387- @show docsdir
388387 @test cp (docsdir, p " cpdstpath" ; force= true ) == p " cpdstpath"
389388 @test ispath (p " cpdstpath" )
390389 @test ispath (p " cpdstpath/src/api.md" )
You can’t perform that action at this time.
0 commit comments