Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-22 Thread Rory Campbell-Lange
On 22/09/22, 'Dan Kortschak' via golang-nuts (golang-nuts@googlegroups.com) wrote: > On Thu, 2022-09-22 at 00:58 +0100, Rory Campbell-Lange wrote: > > interface conversion: *zip.checksumReader is not io.ReadSeeker: > > missing method Seek > > Would it be acceptable to conditionally copy the reade

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Matthew Zimmerman
I've got this same challenge. The contents of any file within a zip needs to be read as a stream, hence why there is no underlying seek method available (assuming to handle the decompression properly) So if you want to seek in a file within a zip, you need to read into a buffer first. You don't h

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
Yea - my bad. Should be fine. > On Sep 21, 2022, at 7:56 PM, 'Dan Kortschak' via golang-nuts > wrote: > > On Wed, 2022-09-21 at 19:30 -0500, robert engels wrote: >> Others have suggested passing a ByteBuffer - I don’t think that will >> work because you will be missing other methods that are pr

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2022-09-21 at 19:30 -0500, robert engels wrote: > Others have suggested passing a ByteBuffer - I don’t think that will > work because you will be missing other methods that are probably > needed (FileInfo to get the name, etc) The function that was pointed to takes an ~io.ReadSeeker (oddly

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
Others have suggested passing a ByteBuffer - I don’t think that will work because you will be missing other methods that are probably needed (FileInfo to get the name, etc) > On Sep 21, 2022, at 7:26 PM, robert engels wrote: > > fs.FS does not support positional reads. It is always the entire

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread robert engels
fs.FS does not support positional reads. It is always the entire file. You can create a wrapper struct that implements the Seek() (trivial - just keep a position and adjust Read() accordingly). > On Sep 21, 2022, at 6:58 PM, Rory Campbell-Lange > wrote: > > I have a program that needs to wo

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread 'Dan Kortschak' via golang-nuts
On Thu, 2022-09-22 at 00:58 +0100, Rory Campbell-Lange wrote: > interface conversion: *zip.checksumReader is not io.ReadSeeker: > missing method Seek > > Advice on how to rectify this would be gratefully received. Would it be acceptable to conditionally copy the reader's contents into a buffer tha

[go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Rory Campbell-Lange
I have a program that needs to work equally for a directory of files or for the contents of a zip file, so I'm using an fs.FS to abstract the two. Some of the files need to be provided to a PDF importer that accepts an io.ReadSeeker (#1). Generally this is working fine except when trying to co