Code Monkey home page Code Monkey logo

Comments (3)

bodgit avatar bodgit commented on August 18, 2024 1

I've merged support for dealing with multiple volumes, just open the file of the first volume, i.e.:

r, err := sevenzip.OpenReader("archive.7z.001")
if err != nil {
        log.Fatal(err)
}
defer r.Close()

from sevenzip.

bodgit avatar bodgit commented on August 18, 2024

Not directly, no.

However the library just wants something that implements the io.ReaderAt interface and as the archive is just the concatenation of its parts, all you need is something similar to io.MultiReader() to join the parts/volumes together but with the right interface. Thankfully such a thing already exists in readerutil.NewMultiReaderAt(). The following code works:

package main

import (
	"errors"
	"io"
	"log"
	"os"

	"github.com/bodgit/sevenzip"
	"go4.org/readerutil"
)

func main() {
	sr := make([]readerutil.SizeReaderAt, 0, len(os.Args[1:]))
	for _, part := range os.Args[1:] {
		f, err := os.Open(part)
		if err != nil {
			log.Fatal(err)
		}
		defer f.Close()

		size, ok := readerutil.Size(f)
		if !ok {
			log.Fatal(errors.New("unable to calculate size"))
		}
		sr = append(sr, io.NewSectionReader(f, 0, size))
	}

	mr := readerutil.NewMultiReaderAt(sr...)

	r, err := sevenzip.NewReader(mr, mr.Size())
	if err != nil {
		log.Fatal(err)
	}

	// Do something with r
}

I'm undecided whether to add this functionality to the library but the above code will work regardless.

from sevenzip.

wotmshuaisi avatar wotmshuaisi commented on August 18, 2024

thanks a lot

from sevenzip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.