Xbase.DbtParser (Xbase v0.1.0)
View SourceParser for DBT (memo) files used in dBase for storing variable-length text data.
DBT files store memo field content in a block-based structure with a 512-byte header followed by fixed-size blocks containing memo data terminated by 0x1A 0x1A markers.
Summary
Functions
Calculates the byte offset for a specific block number.
Closes a DBT file handle.
Extracts memo content from a block, handling termination markers.
Opens a DBT file and parses its header.
Parses a DBT file header from binary data.
Reads memo content from a specific block number.
Validates a DBT file for basic integrity.
Functions
Calculates the byte offset for a specific block number.
Parameters
header- DbtHeader structureblock_number- Block number to calculate offset for
Returns
- Integer byte offset from start of file
Closes a DBT file handle.
Parameters
dbt_file- DbtFile structure from open_dbt/1
Returns
:ok- File closed successfully
Extracts memo content from a block, handling termination markers.
Parameters
block_data- Binary data from a memo block
Returns
{:ok, String.t()}- Extracted memo content{:error, reason}- Error extracting content
Opens a DBT file and parses its header.
Parameters
file_path- Path to the DBT fileversion- DBT format version (optional)
Returns
{:ok, DbtFile.t()}- Successfully opened DBT file{:error, reason}- Error opening or parsing file
Parses a DBT file header from binary data.
Parameters
header_binary- 512 bytes of header dataversion- DBT format version (defaults to :dbase_iii)
Returns
{:ok, DbtHeader.t()}- Successfully parsed header{:error, reason}- Error parsing header
Reads memo content from a specific block number.
Parameters
dbt_file- DbtFile structure from open_dbt/1block_number- Block number to read (1-based, 0 is header)
Returns
{:ok, String.t()}- Memo content{:error, reason}- Error reading block
Validates a DBT file for basic integrity.
Parameters
file_path- Path to the DBT file to validate
Returns
{:ok, boolean()}- Validation result{:error, reason}- Error during validation