ZIPPacker

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also ZIPReader and 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

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 Any

type Any interface {
	gd.IsClass
	AsZIPPacker() Instance
}

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 Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsZIPPacker

func (self *Extension[T]) AsZIPPacker() Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.ZIPPacker

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 New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsZIPPacker

func (self Instance) AsZIPPacker() Instance

func (Instance) Close

func (self Instance) Close() error

Closes the underlying resources used by this instance.

func (Instance) CloseFile

func (self Instance) CloseFile() error

Stops writing to a file within the archive.

It will fail if there is no open file.

func (Instance) CompressionLevel

func (self Instance) CompressionLevel() int

The compression level used when StartFile is called. Use [ZIPPacker.CompressionLevel] as a reference.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) Open

func (self Instance) Open(path string) error

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 (self Instance) SetCompressionLevel(value int)

SetCompressionLevel sets the property returned by [GetCompressionLevel].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) StartFile

func (self Instance) StartFile(path string) error

Starts writing to a file within the archive. Only one file can be written at the same time.

Must be called after Open.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) WriteFile

func (self Instance) WriteFile(data []byte) error

Write the given 'data' to the file.

Needs to be called after StartFile.

type MoreArgs

type MoreArgs [1]gdclass.ZIPPacker

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) Open

func (self MoreArgs) Open(path string, append ZipAppend) error

Opens a zip file for writing at the given path using the specified write mode.

This must be called before everything else.

type ZipAppend

type ZipAppend int //gd:ZIPPacker.ZipAppend
const (
	// Create a new zip archive at the given path.
	AppendCreate ZipAppend = 0
	// Append a new zip archive to the end of the already existing file at the given path.
	AppendCreateafter ZipAppend = 1
	// Add new files to the existing zip archive at the given path.
	AppendAddinzip ZipAppend = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL