BinaryTemplates
Documentation for BinaryTemplates.
BinaryTemplates.BinaryTemplate
BinaryTemplates.EmptyTemplate
BinaryTemplates.HeaderOnlyBinaryTemplate
BinaryTemplates.ZeroTemplate
BinaryTemplates.apply_template
BinaryTemplates.backup_filename
BinaryTemplates.backuptemplate
BinaryTemplates.isexpectedfilesize
BinaryTemplates.load
BinaryTemplates.save
BinaryTemplates.BinaryTemplate
— TypeBinaryTemplate
General binary template with multiple chunks at various file offsets.
Fields
expected_file_size::Int
: Expected size of the fileoffsets::Vector{Int}
: Byte offsets for each chunkchunks::Vector{Vector{UInt8}}
: Bytes for each chunk
BinaryTemplates.EmptyTemplate
— TypeEmptyTemplate
Template containing no chunks.
Field
execpted_file_size::Int = 0
: Expected size of the file
BinaryTemplates.HeaderOnlyBinaryTemplate
— TypeHeaderOnlyBinaryTemplate
AbstractBinaryTemplate that consists of a single chunk at the beginning of the file.
Fields
expected_file_size::Int
: Expected size of the fileheader::Vector{UInt8}
: Chunk of bytes to be written to the template header
BinaryTemplates.ZeroTemplate
— TypeZeroTemplate
AbstractBinaryTemplate where all the chunks consist bytes equal to 0x00
.
Fields
expected_file_size::Int
: Expected size of the fileoffsets::Vector{Int}
: Byte offsets for each chunkchunks_lengths::Vector{Int}
: Length of each chunk
BinaryTemplates.apply_template
— Methodapply_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 not0x00
. Default:true
truncate
- Truncate the file if it is larger than expected. Default:false
BinaryTemplates.backup_filename
— Methodbackup_filename(filename)
Get the backup file name for filename
. This function does not actually backup anything.
BinaryTemplates.backuptemplate
— Methodbackuptemplate(filename::AbstractString, template::AbstractBinaryTemplate)
backuptemplate(io::IO, template::AbstractBinaryTemplate)
Backup the chunks that would be overwritten by the template into a new template.
BinaryTemplates.isexpectedfilesize
— Methodisexpectedfilesize(filename, t::AbstractBinaryTemplate)
Check to see if a file matches the expected filesize of the template.
BinaryTemplates.load
— Functionload([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.save
— Functionsave(template::AbstractBinaryTemplate, filename::AbstractString, mode="w")
Serialize an AbstractBinaryTemplate to a file. It can be reloaded as a BinaryTemplate.