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)
| 254 | // name has a ".001" suffix it is assumed there are multiple volumes and each |
| 255 | // sequential volume will be opened. |
| 256 | func 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 |
searching dependent graphs…