MhcPatcher:Patch file structure
Patch file structure
Patch files are actually XML files (with mhcp extension) containing directives to drive file modifications.
Their structure is as follows:
<MHCPatcher> <Description> Description of the patch and which hardware it supports </Description> <Notes> Notes about the patch file </Notes> <Target file="file to be patched, relative path from Harmony installation folder"> <Patch SearchRegEx="RegEx to search for insertion/replace point" Action="InsertBefore|InsertAfter|Replace" Check="string to be searched to check if the patch has been already applied"> Patch contents </Patch> <Patch..........> Other modifications in other places for the same Target file </Patch> </Target> <Target........> Other target file to be modified <Patch........> </Patch> </Target> ... <AddFile Source="source path of file to be added" Target="destination path of the file to be added" /> <AddFile...... /> ... </MHCPatcher>
Basic Operation Outline
When you choose to apply the patch, the file specified in the Target tag is read into memory and
- A simple search for the string specified in Check tag is performed, to see if the patch has already been applied.
If no Check tag is specified, the entire Patch contents are searched inside the Target file. If Check text is found, no further interventions for this patch is done, and the relative row on the tree view goes green.
- If the patch has to be applied, a search for a block of text that matches the Regular Expression specified in SearchRegEx tag is performed.
This determines the Insertion Point.
- When Action tag is InsertBefore the Patch contents are inserted before the matched text.
- When Action tag is InsertAfter the Patch contents are inserted after the matched text.
- When Action tag is Replace the Patch contents are used to replace the entire matched text.
If present, AddFile tags are precessed, copying Source file to Target file.
Source file must be supplied in the patch folder from the repository along with the .mhcp patch file itself.
Target file path is relative to Harmony installation folder i.e.