MCPcopy Create free account
hub / github.com/bodgit/sevenzip / Open

Method Open

reader.go:315–337  ·  view source on GitHub ↗

Open opens the named file in the 7-zip archive, using the semantics of [fs.FS.Open]: paths are always slash separated, with no leading / or ../ elements.

(name string)

Source from the content-addressed store, hash-verified

313// [fs.FS.Open]: paths are always slash separated, with no leading / or ../
314// elements.
315func (z *Reader) Open(name string) (iofs.File, error) {
316 z.initFileList()
317
318 if !iofs.ValidPath(name) {
319 return nil, &iofs.PathError{Op: "open", Path: name, Err: iofs.ErrInvalid}
320 }
321
322 e := z.openLookup(name)
323 if e == nil {
324 return nil, &iofs.PathError{Op: "open", Path: name, Err: iofs.ErrNotExist}
325 }
326
327 if e.isDir {
328 return &openDir{e, z.openReadDir(name), 0}, nil
329 }
330
331 rc, err := e.file.Open()
332 if err != nil {
333 return nil, err
334 }
335
336 return rc.(iofs.File), nil //nolint:forcetypeassert
337}
338
339func (z *Reader) folderReader(si *streamsInfo, f int) (*folderReadCloser, uint32, bool, error) {
340 // Create a SectionReader covering all of the streams data

Callers

nothing calls this directly

Calls 4

initFileListMethod · 0.95
openLookupMethod · 0.95
openReadDirMethod · 0.95
OpenMethod · 0.45

Tested by

no test coverage detected