From cbd9e9049257d29227db5bdd122f20779ab7dbab Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 17 Mar 2022 12:44:16 -0700 Subject: [PATCH 1/2] Add `readavailable(::FileBuffer)` This adds a method for `FileBuffer`s to `readavailable` that precisely matches the behavior for `IOBuffer`s. This definition permits downstream niceties such as `CSV.read(::S3Path, ...)`. --- src/buffer.jl | 1 + test/buffer.jl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/buffer.jl b/src/buffer.jl index f258742..48bc4b5 100644 --- a/src/buffer.jl +++ b/src/buffer.jl @@ -35,6 +35,7 @@ end Base.isopen(buffer::FileBuffer) = isopen(buffer.io) Base.isreadable(buffer::FileBuffer) = buffer.read Base.iswritable(buffer::FileBuffer) = buffer.write +Base.readavailable(buffer::FileBuffer) = read(buffer) Base.seek(buffer::FileBuffer, n::Integer) = (_read(buffer); seek(buffer.io, n)) Base.skip(buffer::FileBuffer, n::Integer) = (_read(buffer); skip(buffer.io, n)) Base.seekstart(buffer::FileBuffer) = seekstart(buffer.io) diff --git a/test/buffer.jl b/test/buffer.jl index 819c686..e90092d 100644 --- a/test/buffer.jl +++ b/test/buffer.jl @@ -33,6 +33,8 @@ using FilePathsBase: FileBuffer close(io) end + @test readavailable(FileBuffer(p)) == readavailable(IOBuffer(read(p))) + # issue #126: data on first read mktemp(SystemPath) do p, _ write(p, "testing") From 355420fae54aba5fb3a85e0dbad2dc61ff7e568d Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 17 Mar 2022 12:46:40 -0700 Subject: [PATCH 2/2] Bump version to 0.9.18 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7f605b6..6ba52ea 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FilePathsBase" uuid = "48062228-2e41-5def-b9a4-89aafe57970f" authors = ["Rory Finnegan"] -version = "0.9.17" +version = "0.9.18" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"