Documentation
¶
Overview ¶
This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also graphics.gd/classdb/ZIPReader and graphics.gd/classdb/PCKPacker.
package main import "graphics.gd/classdb/ZIPPacker" func WriteZipFile() error { var writer = ZIPPacker.New() var err = writer.Open("user://archive.zip") if err != nil { return err } writer.StartFile("hello.txt") writer.WriteFile([]byte("Hello World")) writer.CloseFile() writer.Close() return nil }
Index ¶
- type Advanced
- type Any
- type CompressionLevel
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsZIPPacker() Instance
- func (self Instance) Close() error
- func (self Instance) CloseFile() error
- func (self Instance) CompressionLevel() int
- func (self Instance) ID() ID
- func (self Instance) Open(path string) error
- func (self Instance) SetCompressionLevel(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) StartFile(path string) error
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) WriteFile(data []byte) error
- type ZipAppend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type CompressionLevel ¶
type CompressionLevel int //gd:ZIPPacker.CompressionLevel
const ( // Start a file with the default Deflate compression level (6). This is a good compromise between speed and file size. CompressionDefault CompressionLevel = -1 // Start a file with no compression. This is also known as the "Store" compression mode and is the fastest method of packing files inside a ZIP archive. Consider using this mode for files that are already compressed (such as JPEG, PNG, MP3, or Ogg Vorbis files). CompressionNone CompressionLevel = 0 // Start a file with the fastest Deflate compression level (1). This is fast to compress, but results in larger file sizes than [CompressionDefault]. Decompression speed is generally unaffected by the chosen compression level. CompressionFast CompressionLevel = 1 // Start a file with the best Deflate compression level (9). This is slow to compress, but results in smaller file sizes than [CompressionDefault]. Decompression speed is generally unaffected by the chosen compression level. CompressionBest CompressionLevel = 9 )
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsZIPPacker ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsZIPPacker ¶
func (Instance) CloseFile ¶
Stops writing to a file within the archive.
It will fail if there is no open file.
func (Instance) CompressionLevel ¶
func (Instance) Open ¶
Opens a zip file for writing at the given path using the specified write mode.
This must be called before everything else.
func (Instance) SetCompressionLevel ¶
func (Instance) StartFile ¶
Starts writing to a file within the archive. Only one file can be written at the same time.
Must be called after Instance.Open.