BinaryTemplates

Documentation for BinaryTemplates.

BinaryTemplates.BinaryTemplateType
BinaryTemplate

General binary template with multiple chunks at various file offsets.

Fields

  • expected_file_size::Int: Expected size of the file
  • offsets::Vector{Int}: Byte offsets for each chunk
  • chunks::Vector{Vector{UInt8}}: Bytes for each chunk
BinaryTemplates.HeaderOnlyBinaryTemplateType
HeaderOnlyBinaryTemplate

AbstractBinaryTemplate that consists of a single chunk at the beginning of the file.

Fields

  • expected_file_size::Int: Expected size of the file
  • header::Vector{UInt8}: Chunk of bytes to be written to the template header
BinaryTemplates.ZeroTemplateType
ZeroTemplate

AbstractBinaryTemplate where all the chunks consist bytes equal to 0x00.

Fields

  • expected_file_size::Int: Expected size of the file
  • offsets::Vector{Int}: Byte offsets for each chunk
  • chunks_lengths::Vector{Int}: Length of each chunk
BinaryTemplates.apply_templateMethod
apply_template(target_filename, template::AbstractBinaryTemplate; backup_filename, ensure_zero=true, truncate=false)

Apply an AbstractBinaryTemplate to target_filename by writing chunks to the appropriate offsets.

The file will be enlarged to expected_file_size(template).

Keywords

  • backup_filename - Name of the file to store the backup template. Default: BinaryTemplates.backup_filename(target_filename).
  • ensure_zero - Throws an error if the bytes to be overwritten are not 0x00. Default: true
  • truncate - Truncate the file if it is larger than expected. Default: false
BinaryTemplates.backuptemplateMethod
backuptemplate(filename::AbstractString, template::AbstractBinaryTemplate)
backuptemplate(io::IO, template::AbstractBinaryTemplate)

Backup the chunks that would be overwritten by the template into a new template.

BinaryTemplates.loadFunction
load([BinaryTemplate, ]filename::AbstractString, index=1)

Load a BinaryTemplate from a file. By default, the first saved BinaryTemplate will be loaded. Subsequent templates may be accessed via by setting a larger index.

BinaryTemplates.saveFunction
save(template::AbstractBinaryTemplate, filename::AbstractString, mode="w")

Serialize an AbstractBinaryTemplate to a file. It can be reloaded as a BinaryTemplate.