-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archiver.FileSystem() alternative that takes io.Reader #358
Comments
You want Thanks for using archiver! (If I've misunderstood your request, feel free to let me know.) |
It worked, thank you! However it was pretty hard to figure out how to use this correctly. It was crashing on me until |
Oh... if you don't know the format ahead of time, I guess that can be a little tricky; because Identify() reads some of the bytes, so you have to use the new reader it returns. I didn't realize you had an unknown format. Maybe we can add an exported API for calling FileSystem on a stream... |
Yeah... this is what I have right now: f, _ := os.Open("foo.zip")
s, _ := f.Stat()
i, _, _ := archiver.Identify(f.Name(), f)
a := &archiver.ArchiveFS{
Stream: io.NewSectionReader(f, 0, s.Size()),
Format: i.(archiver.Archival),
}
a.Sub(".") So I guess I could reopen f after Indentify()? But still this is little cumbersome. It would be super nice if |
M'kay, I'll leave this open and give it some thought. I'd also accept a proposal to review for quicker turnaround! |
Well, this is fantastic, thank you! But I have a more sophisticated case with which I'm, ahem, a bit stuck..
So, on each layer of abstraction I have an As a wild guess, I've made a breaking experiment. I've changed
And surprisingly managed to reach up to point number 3 in my unusual journey, but not further, unfortunately.... Any hints would be appreciated! The idea behind this is pretty simple: you navigate to a web resource which serves you a list of iso files from a directory on disk. You can dig into iso contents by clicking on corresponding name and navigate deeper and deeper, digging inside all known file types. [1]: Debian binary package (a |
@aol-nnov Interesting -- thanks for chiming in. Any reason you can't make the Stream field an
What happened after that? |
@mholt I'm still new to go and some things seem unusual/unexpected, ha!
Indeed, seems, that pointer type was another issue. I'll experiment more with it soon! Thank you for the hint!
Seems, I've hit another issue, #371 may be. I can list the top-level dir of |
Hey, @mholt !
I do not have any as yet! I think you have me confused with someone else :) Do you want me to make a PR for |
My bad, you're right -- I guess I'd be curious to see the patch, though -- no guarantees it'll be merged, but curious what it looks like! |
@mholt nothing fancy there, but, okay, I'll arrange it soon |
Wild guesses and musings on mholt#358
What would you like to have changed?
In addition to
archiver.FileSystem("filename.ext")
there should be a function that takesio.Reader
or betterio.ReaderAt
andsize
. For examplearchiver.NewFsReader(r io.ReaderAt, size int64)
.Why is this feature a useful, necessary, and/or important addition to this project?
This is necessary to use a file thats already open or for files that do not resize on OS filesystem and cannot be opened with
os.Open()
. For example afero or any other virtual/in memory file system.What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?
There are no alternatives, currently I can't use archiver.FileSystem with a file on a synthetic FS because archiver assumes the file can be opened with os.Open().
Please link to any relevant issues, pull requests, or other discussions.
Go archive/zip implements NewReader in addition to file Open.
https://pkg.go.dev/archive/zip#NewReader
Similarly SevenZip:
https://pkg.go.dev/github.com/bodgit/sevenzip?utm_source=godoc#NewReader
Thank you!
The text was updated successfully, but these errors were encountered: