Modular Shockwave Flash reader, parser and decoder in Go.
Go to file
2023-12-03 04:54:51 +01:00
subtypes Initial commit, ported from swf2ass-go 2023-12-02 01:46:09 +01:00
tag Fix DefineFont tag length of offsets 2023-12-03 04:54:51 +01:00
types Initial commit, ported from swf2ass-go 2023-12-02 01:46:09 +01:00
go.mod Initial commit, ported from swf2ass-go 2023-12-02 01:46:09 +01:00
go.sum Initial commit, ported from swf2ass-go 2023-12-02 01:46:09 +01:00
LICENSE Initial commit, ported from swf2ass-go 2023-12-02 01:46:09 +01:00
reader.go Implement Close() for reader in case ZLIB is used in decompressor 2023-12-02 02:23:37 +01:00
README.md Use golang in Markdown code instead of go 2023-12-02 02:25:32 +01:00

swf-go

Modular Shockwave Flash reader, parser and decoder in Go.

Compared to kelvyne/swf, it also decodes types and Tag contents, including sprites.

Example

package example

import (
    "errors"
    "git.gammaspectra.live/WeebDataHoarder/swf-go"
    "git.gammaspectra.live/WeebDataHoarder/swf-go/tag"
    "io"
    "os"
)

func main() {
    f, err := os.Open("flash.swf")
    if err != nil {
        panic(err)
    }
    defer f.Close()

    reader, err := swf.NewReader(f)
    if err != nil {
        panic(err)
    }
    defer reader.Close()

    for {
        t, err := reader.Tag()
        if err != nil {
            if errors.Is(err, tag.ErrUnknownTag) {
                //unknown tag, cannot decode
                continue
            }
            if errors.Is(err, io.EOF) {
                //file is completely read
                panic("EOF reached without End tag")
            }
            panic(err)
        }

        //Handle tags
        switch t.(type) {
            case *tag.End:
            //end of file
            break
        }
    }
}