Documentation
¶
Overview ¶
Package replace 提供 OFD 包内条目的替换、新增与删除能力。
替换按包内路径(如 "Doc_0/Pages/Page_0/Content.xml")操作,不解析页面或 资源模型:命中的条目用新字节覆盖,其余条目原样搬运。由于任何字节改动都会 使已有签名摘要失效,Options.Signatures 默认丢弃签名目录;需要保留时可显式 选择 preserve 或 rewrite。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Operation ¶
type Operation struct {
// Kind 是操作类型。
Kind OperationKind
// Name 是包内路径,不带前导斜杠。
Name string
// Data 是 Set/Add 的新字节内容。
Data []byte
}
Operation 描述一次条目操作。
type OperationKind ¶
type OperationKind string
OperationKind 描述对某个包内条目的操作类型。
const ( // OpSet 替换已有条目,条目不存在时报错。 OpSet OperationKind = "set" // OpAdd 新增条目,条目已存在时报错。 OpAdd OperationKind = "add" // OpDelete 删除已有条目,条目不存在时报错。 OpDelete OperationKind = "delete" )
type Options ¶
type Options struct {
// Compression 是输出 ZIP 的压缩策略,空值时按条目类型自动选择。
Compression creator.CompressionMode
// CompressionLevel 是 DEFLATE 压缩级别,0 使用默认级别 5,显式范围
// 1(最快)到 9(最紧凑)。仅对实际使用 Deflate 的条目生效。
CompressionLevel int
// Deterministic 使用固定 ZIP 时间,生成可复现的结果。
Deterministic bool
// Signatures 是签名处理方式,空值跳过签名处理。
Signatures creator.SignatureMode
// Limits 限制输入与输出的规模,零值使用默认限制。
Limits Limits
// Validate 在输出后执行严格 OFD 校验。
Validate bool
// SkipXMLCheck 关闭默认的 XML 良构检查;Set/Add 的新内容若命中 .xml 条目,
// 默认会先解析校验,防止写入格式损坏的 XML。
SkipXMLCheck bool
// OnWarning 可选,接收非致命提示,例如签名被保留但摘要已失效。
OnWarning func(string)
}
Options 控制替换输出方式。
Click to show internal directories.
Click to hide internal directories.