Customizing File Types-II |
Currently R-Studio supports two versions of file type descriptions. Version 2 extends legacy Version 1 by adding variable signature offsets and AND/OR combination of several signatures in one file type. The version of file type description is specified by the version attribute of the FileTypeList section . Version 1 is the default option. File structure Elements common to Versions 1 and 2 of file type description File header The file starts with a standard XML header <?xml version="1.0" encoding="utf-8"?> Section FileTypeList <FileTypeList> Attributes:
It requires a closing element </FileTypeList>. Comments <!-- Comment string --> An XML-standard string for a comment. Version 1 of file type description Signature file example <FileTypeList> <FileType id="2" group="archive" description="ARJ Archive" extension="arj"> <Signature offset="3" count="1">Abc\x5c\x00\x04</Signature> <Signature offset="9" count="2">\x23\x01\xf4</Signature> </FileType> </FileTypeList> Section FileType This is a description of each file signature. Attributes:
File type properties flags
List of predefined file type groups
This section can contain an unlimited number of the Signature elements.If there are several Signature elements, that means that all those signatures are simultaneously present in the file. Such signatures should have different offset attributes and they should not overlap. Element Signature The element contains a string value of the file signature consisting of ASCII characters and hex bytes in the \xhh format, where hh is a hexadecimal byte code. If that is not a hexadecimal number after \x, \x are treated as a part of the string section of the signature Attributes:
Version 2 of file type description Signature file example <?xml version="1.0" encoding="utf-8"?> <FileTypeList version="2.0"> <FileType id="5626" group="_Test" description="Test file" extension="tst"> <Begin combine="and"> <Signature from="0" to="20">ABC</Signature> <Signature offset="1">CDEFG</Signature> <AND> <Signature offset="0">DE</Signature> <Signature offset="0">RTD</Signature> <OR> <Signature offset="12">CP</Signature> <Signature offset="16">RTD</Signature> </OR> </AND> </Begin> <End combine="or"> <Signature from="3" to="20">ABC</Signature> <Signature offset="5">CDEFG</Signature> <AND> <Signature offset="2">DE</Signature> <Signature offset="3">RTD</Signature> <OR> <Signature offset="12">CP</Signature> <Signature offset="16">RTD</Signature> </OR> </AND> </End> </FileType> </FileTypeList> Section FileType This is a description of each file signature. Attributes: Similar to those in Version 1. The section can contain one element Begin and one End. It should contain at least one of them. Example <FileTypeList version=2.0> <FileType id="2" group="archive" description="ARJ Archive" extension="arj"> <Begin [attributes]> ... </Begin> <End [attributes]> ... </End> </FileType> </FileTypeList> Sections Begin and End Specify the positions of file type signatures in the file. Attributes
These sections can contain one of several elements Signature. And one or several elements OR or AND. If there are several elements inside the section they are combined according to the attribute combine. Example: <FileTypeList version=2.0> <FileType id="2" group="archive" description="ARJ Archive" extension="arj"> <Begin combine="or"> <Signature [attributes]> ... </Signature> ... <Signature [attributes]> ... </Signature> <AND> ... </AND> <OR> ... </OR> </Begin> <End> <OR> ... </OR> <Signature [attributes]> ... </Signature> ... <Signature [attributes]> ... </Signature> </End> </FileType> </FileTypeList> Sections AND and OR These sections can contain one of several elements Signature. And one or several elements OR or AND. If there are several elements inside the section they are combined according to the section type (logical AND or OR). Example: <FileTypeList version=2.0> <FileType id="2" group="archive" description="ARJ Archive" extension="arj"> <Begin> <Signature [attributes]> ... </Signature> ... <Signature [attributes]> ... </Signature> <AND> <Signature [attributes]> ... </Signature> <OR> <Signature [attributes]> ... </Signature> <AND> <Signature [attributes]> ... </Signature> <Signature [attributes]> ... </Signature> </AND> <OR> <Signature [attributes]> ... </Signature> <Signature [attributes]> ... </Signature> </OR> </OR> <Signature [attributes]> ... </Signature> </AND> </Begin> </FileType> </FileTypeList> Element Signature The element contains a string value of the file signature consisting of ASCII characters and hex bytes in the \xhh format, where hh is a hexadecimal byte code. If that is not a hexadecimal number after \x, \x are treated as a part of the string section of the signature Attributes:
Example: <FileTypeList version=2.0> <FileType id="2" group="archive" description="ARJ Archive" extension="arj"> <Begin> <Signature offset="3">Abc\x5c\x00\x04</Signature> <Signature from="9" to="15">\x23\x01\xf4</Signature> </Begin> </FileType> </FileTypeList> |