I am trying to understand the file format of a Visual FoxPro compact index (*.IDX). I am currently referring to Microsoft's documentation for guidance.
The index is a B-tree of 512-byte nodes. Each leaf ("exterior") node contains multiple entries. Each entry consists of four pieces of data:
- Row number [FIXED LENGTH]
- Duplicate byte count (documentation doesn't explain this) [FIXED LENGTH]
- Trailing byte count (documentation doesn't explain this) [FIXED LENGTH]
- Key [VARIABLE LENGTH]
The entries (without their keys) are stored at the beginning of the node, immediately after the node's 24-byte header. Their keys are not included at this location because the keys vary in length, while the row number, duplicate byte count and trailing byte counts are fixed in length. The keys are stored at the end of the node and work their way backward. For example:
- 24 byte header
- row number, duplicate byte count, trailing byte count (entry #1)
- row number, duplicate byte count, trailing byte count (entry #2)
- row number, duplicate byte count, trailing byte count (entry #3)
- ...
- key (entry #3)
- key (entry #2)
- key (entry #1)
How do I determine the individual lengths of the keys? The documentation does not appear to specify this. They are perfectly contiguous (no null-byte separators).
I can isolate the keys manually by visual inspection. I suspected that the trailing byte count represented the length of the key. However, it did not correlate to the lengths determined by this inspection.
I believe that the FoxPro file formats are derived from the xBase standard. Perhaps this rings a bell?