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

Function OpenReaderWithPassword

reader.go:256–279  ·  view source on GitHub ↗

OpenReaderWithPassword will open the 7-zip file specified by name using password as the basis of the decryption key and return a [*ReadCloser]. If name has a ".001" suffix it is assumed there are multiple volumes and each sequential volume will be opened.

(name, password string)

Source from the content-addressed store, hash-verified

254// name has a ".001" suffix it is assumed there are multiple volumes and each
255// sequential volume will be opened.
256func OpenReaderWithPassword(name, password string) (*ReadCloser, error) {
257 reader, size, files, err := openReader(afero.NewOsFs(), name)
258 if err != nil {
259 return nil, err
260 }
261
262 r := new(ReadCloser)
263 r.p = password
264
265 if err := r.init(reader, size); err != nil {
266 errs := make([]error, 0, len(files)+1)
267 errs = append(errs, err)
268
269 for _, file := range files {
270 errs = append(errs, file.Close())
271 }
272
273 return nil, fmt.Errorf("sevenzip: error initialising: %w", errors.Join(errs...))
274 }
275
276 r.f = files
277
278 return r, nil
279}
280
281// OpenReader will open the 7-zip file specified by name and return a
282// [*ReadCloser]. If name has a ".001" suffix it is assumed there are multiple

Callers 4

benchmarkArchiveFunction · 0.92
OpenReaderFunction · 0.85

Calls 3

openReaderFunction · 0.85
initMethod · 0.80
CloseMethod · 0.45

Tested by 3

benchmarkArchiveFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…