# custom.ini file format

In the standard distribution of MultiArc there's a limited number of FMT-modules supporting most commonly used archivers. Among them there's the CUSTOM.FMT module which allows to define "missing" archivers by defining the archiver's output listing format. For these descriptions the CUSTOM.INI file is used.

Each new archive type is defined within individual [Archive Name] sections used for archive type name. The following parameters are used in this section:

TypeName (optional parameter)
overrides format name defined in the section name (left for compatibility reasons)
ID (optional parameter)
archive identifier - a sequence of space delimited two-digit hex numbers (i.e. the "`ID=1a 4a 61 72 1b`" sequence defines JAR archive identifier)
IDOnly (optional parameter)
"archive identifier only". If it's set to "1" file extension is ignored and archive type is determined by the ID field only. If it's "0" then both file extension and ID field (if it's defined in this section) are used to determine archive type.
IDPos (optional parameter)
position from which CUSTOM.FMT begins to look for the archive identifier (ID). If the field is not defined then the ID is searched from the beginning of the file. By default FAR "gives" to the plugin the first 128K of data.
Extension
archive extension (without '.').
List
external archiver command for file listing. Archive name is added after this string. For example, for `List="jar32 v -y"` field the `jar32 v -y archive_name` command will be composed.
Errorlevel (optional parameter)
listing analysis is performed only if archiver's exit code is less than the one defined in the Errorlevel parameter.
IgnoreErrors (optional parameter)
if it's not 0 then archiver's exit code is ignored. Use with caution!
Start (optional parameter)
substring which defines the beginning of the listing analysis. If the string begins with the '`^`' symbol then the search for substring is performed starting from the second symbol of the current line in the listing.
End (optional parameter)
substring which defines the end of the listing analysis. If the string begins with the '`^`' symbol then search for substring is performed starting from the second symbol the current line in the listing.
Format0 ... FormatN
parameters describing the record for a single archive element. Each parameter describes an ordinary record string, allowing the following codes:

Code | Description
--- | ---
n | file name
. | remove trailing spaces from file name and append name with dot
z | file size
c | file description
p | packed file size
d | day
t | month
TTT | three letters of month name (Jan, Feb, Mar, ...)
y | year
h | hours
H | hours modifier letter (a - a.m. time, p - p.m. time)
m | minutes
s | seconds
a | file attributes
* | skip until first space or end of line
b | day of last access
v | month of last access
e | year of last access
x | hours of last access
l | minutes of last access
k | seconds of last access
j | day of creation
g | month of creation
f | year of creation
o | hours of creation
i | minutes of creation
u | seconds of creation
r | CRC (hex)
C | Chapter descriptions field
(<number>) | optional digits, some or all digits may be missing

If the string begins with the '`^`' symbol then search for substring is performed starting from the second symbol of the current line in the listing.
IgnoreString0 ... IgnoreStringN
parameters defining strings which are ignored by the module in the listing analysis. If the string begins with the '`^`' symbol then search for substring is performed starting from the second symbol of current line in the listing.
Extract ... MoveRecurse
parameters describing archiver commands.

Command | Description
--- | ---
Extract | unpack
ExtractWithoutPath | unpack without paths
Test | test archive
Delete | delete files from archive
Comment | add archive comment
CommentFiles | add files comment
SFX | convert to SFX
Lock | lock archive
Protect | add recovery record
Recover | recover damaged archive
Add | add files
Move | move files to archive
AddRecurse | add files with recursive folder tree traversal
MoveRecurse | move files with recursive folder tree traversal

Pseudo-variables described here can be used in external archivers' command lines for different archive processing purposes.
AllFilesMask
"All Files" mask

## Regular expressions

Regular expressions (Perl5 syntax) can be used in the following parameters: FormatX, IgnoreStringX, Start, End. To specify that a pattern should be matched as a regular expression, enclose it in slashes ('/'). The following regexp flags can be used (if corresponding characters are placed after closing slash):

Flag | Description
--- | ---
`i` | ignore case
`x` | extended (use explaining spaces)

The following open source library is used to process regular expressions: PCRE (by Philip Hazel, copyright by the University of Cambridge, England).

When using regexps in the FormatX parameter, named strings (of the form `(?P<name>\w+)`) are used to extract information from listing lines. The following field names are available:

Field | Description
--- | ---
name | file name with relative path (leading and trailing spaces are trimmed)
description | file description
size | unpacked file size in bytes (non-digit characters are ignored in this and all other numeric fields)
packedSize | packed file size in bytes
attr | file attributes (A - archive, R - readonly, S - system, C - compressed, H - hidden, D - directory)
cYear, cDay, cMonth, cHour, cMin, cSec | creation time
mYear, mDay, mMonth, mHour, mMin, mSec | modification time
mAMPM, mMonthA | extended time fields for modification time
aYear, aDay, aMonth, aHour, aMin, aSec | access time
CRC | 32 bit file Cyclic Redundancy Checksum (CRC)

For example to process the following listing:

     Volume in drive D is work
     Volume Serial Number is xxxx-xxxx

     Directory of D:\works\MultiArc\final\Formats

    15.11.2004  07:15    <DIR>          .
    15.11.2004  07:15    <DIR>          ..
    14.11.2004  00:46             5 632 Ace.fmt
    14.11.2004  00:46             4 608 Arc.fmt
    14.11.2004  00:46             6 656 Arj.fmt
    14.11.2004  00:46             6 144 Cab.fmt
    15.11.2004  06:07            56 832 Custom.fmt
    15.11.2004  07:14             1 551 custom.ini-re
    15.11.2004  07:11            54 344 Formats.jkr
    14.11.2004  00:46             4 608 Ha.fmt
    14.11.2004  00:46             6 144 Lzh.fmt
    15.11.2004  07:15                 0 out
    14.11.2004  00:46             6 144 Rar.fmt
    14.11.2004  00:46             9 216 TarGz.fmt
    14.11.2004  00:46             6 656 Zip.fmt
                  13 File(s)        168 535 bytes
                   2 Dir(s)  37 840 883 712 bytes free

the following settings are used:

    Start="/^ Directory of/"
    End="/File\(s\)/"
    Format0="/^(?P<cDay>\d+).(?P<cMonth>\d+).(?P<cYear>\d+)\s+ (?P<cHour>\d+):(?P<cMin>\d+)\s+(?P<packedSize>[\d\xff]+)\s(?P<name>.*?)\s*$/"

The following settings:

    Start="/^..reading directory/"
    End="/^..listing completed/"
    Format0="/^[^\|]*\|(?P<size>[^\|]+)\|(?P<attr>[^\|]+)\|\s+(?P<name>.*?)\s*$/"
    IgnoreString0="/^---- ---- ---- ----/"

can be used to process this listing:

    jkRes utility version 002
      pack/unpack tool to work with jkRes resource bundles

    ..listing files from resource bundle
    ..reading directory...12 items found
    ---- ---- ---- ----
        zlib |     5632 | A.... | Ace.fmt
        zlib |     4608 | A.... | Arc.fmt
        zlib |     6656 | A.... | Arj.fmt
        zlib |     6144 | A.... | Cab.fmt
        zlib |    56832 | A.... | Custom.fmt
        zlib |     4608 | A.... | Ha.fmt
        zlib |     6144 | A.... | Lzh.fmt
        zlib |     6144 | A.... | Rar.fmt
        zlib |     9216 | A.... | TarGz.fmt
        zlib |     6656 | A.... | Zip.fmt
        zlib |    13012 | A.... | Custom.ini
        zlib |     1072 | A.... | custom.ini-re
    ---- ---- ---- ----
    ..listing completed
    ..done

See also:
archive support