entrywriter

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package entrywriter 提供带规模限制与确定性选项的 OFD ZIP 条目写入器, 供 ZIP 级处理工具(如 pkg/merge、pkg/replace)复用。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Compression 是输出 ZIP 的压缩策略,空值使用 creator.CompressionAuto。
	Compression creator.CompressionMode
	// CompressionLevel 是 DEFLATE 压缩级别,0 使用默认级别 5,显式范围
	// 1(最快)到 9(最紧凑)。仅对实际使用 Deflate 的条目生效。
	CompressionLevel int
	// Deterministic 使用固定 ZIP 时间,生成可复现的结果。
	Deterministic bool
	// Limits 限制输出规模,零值使用 creator 的默认限制。
	Limits creator.Limits
	// OnWarning 可选,接收非致命提示。
	OnWarning func(string)
}

Config 控制条目写入的压缩策略与规模限制。

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer 向归档写入受限的 ZIP 条目,拒绝非法或重复路径,并遵守压缩与 确定性设置。

func New

func New(archive *zip.Writer, config Config) *Writer

New 创建写入器并套用默认规模限制。调用方负责在写完后关闭 archive。 若 CompressionLevel 无效,回退默认级别并通过 OnWarning 上报。

func (*Writer) MaxEntryBytes

func (w *Writer) MaxEntryBytes() int64

MaxEntryBytes 返回当前单条解压字节上限。

func (*Writer) Warn

func (w *Writer) Warn(message string)

Warn 通过 Config.OnWarning 上报非致命提示。

func (*Writer) Write

func (w *Writer) Write(name string, data []byte) error

Write 按压缩策略与确定性选项写入一个内存条目。

func (*Writer) WriteSource

func (w *Writer) WriteSource(pkg *core.Package, entry core.Entry, name string) error

WriteSource 流式写入输入包中的条目,避免资源整体驻留内存。

Jump to

Keyboard shortcuts

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