FAQ
Hi,

I'd like to append a zip at the end of an executable - like sfx, but esp.
for resource embedding.

I have two workarounds:
a) github.com/tgulacsi/go/zipA/azip/unsafe.go : use unsafe to make the
countWriter's count settable;
b) github.com/tgulacsi/go/zipA/zip2 : copy archive/zip's needed struct.go,
register.go and writer.go files, and add wrap zip2.Writer.

but adding the following 3 lines would be much-much easier and (IMHO) nicer:

// NewWriterOffset returns a new Writer writing a zip file to w.
// This sets the writer's offset to the given value, with the effect
// of having all offsets in the headers biased.
// This is useful for appending zips to other files - think sfx.
func NewWriterOffset(w io.Writer, offset int64) *Writer {
         return &Writer{cw: &countWriter{w: bufio.NewWriter(w), count:
offset}}
}


What do you think?

Thanks,
Tamás Gulácsi

--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Minux at Apr 29, 2014 at 8:17 pm

    On Tue, Apr 29, 2014 at 2:53 PM, Tamás Gulácsi wrote:

    I'd like to append a zip at the end of an executable - like sfx, but esp.
    for resource embedding.

    I have two workarounds:
    a) github.com/tgulacsi/go/zipA/azip/unsafe.go : use unsafe to make the
    countWriter's count settable;
    b) github.com/tgulacsi/go/zipA/zip2 : copy archive/zip's needed
    struct.go, register.go and writer.go files, and add wrap zip2.Writer.

    but adding the following 3 lines would be much-much easier and (IMHO)
    nicer:

    // NewWriterOffset returns a new Writer writing a zip file to w.
    // This sets the writer's offset to the given value, with the effect
    // of having all offsets in the headers biased.
    // This is useful for appending zips to other files - think sfx.
    func NewWriterOffset(w io.Writer, offset int64) *Writer {
    return &Writer{cw: &countWriter{w: bufio.NewWriter(w), count:
    offset}}
    }
    Why not just pass a append-only Writer to zip.NewWriter?

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrew Gerrand at Apr 30, 2014 at 3:08 am
    On 29 April 2014 14:17, minux wrote:
    On Tue, Apr 29, 2014 at 2:53 PM, Tamás Gulácsi wrote:

    I'd like to append a zip at the end of an executable - like sfx, but esp.
    for resource embedding.

    I have two workarounds:
    a) github.com/tgulacsi/go/zipA/azip/unsafe.go : use unsafe to make the
    countWriter's count settable;
    b) github.com/tgulacsi/go/zipA/zip2 : copy archive/zip's needed
    struct.go, register.go and writer.go files, and add wrap zip2.Writer.

    but adding the following 3 lines would be much-much easier and (IMHO)
    nicer:

    // NewWriterOffset returns a new Writer writing a zip file to w.
    // This sets the writer's offset to the given value, with the effect
    // of having all offsets in the headers biased.
    // This is useful for appending zips to other files - think sfx.
    func NewWriterOffset(w io.Writer, offset int64) *Writer {
    return &Writer{cw: &countWriter{w: bufio.NewWriter(w), count:
    offset}}
    }
    Why not just pass a append-only Writer to zip.NewWriter?
    Because the zip writer needs to know the correct offsets to write into the
    directory entries.

    I think this is weird enough that you should just fork the library, if you
    need to do this.

    Andrew

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tamás Gulácsi at Apr 30, 2014 at 4:23 pm
    Thanks all - esp. for suggesting go-bindata! This works as adversed.

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedApr 29, '14 at 6:53p
activeApr 30, '14 at 4:23p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase