Defining filetypes with p4 typemap
Helix Server
uses the filesys.binaryscan
configurable to determine how
many bytes to examine when determining if a file is of type
text
or binary
. By default,
filesys.binaryscan
is 65536; if the high bit is clear in the
first 65536 bytes,
Helix Server
assumes it to be text
; otherwise, it is assumed to be
binary
. Files compressed in the .zip
format
(including .jar
files) are also automatically detected and
assigned the type ubinary
.
Although this default behavior can be overridden by the use of the
-t filetype
flag, it’s easy for users to overlook
this consideration, particularly in cases where files' types are usually
(but not always) detected correctly. Certain file formats, such as RTF
(Rich Text Format) and Adobe PDF (Portable Document Format), can start
with a series of comment fields or other textual data. If these comments
are sufficiently long, such files can be erroneously detected by
Helix Server
as being of type text
.
The p4 typemap
command solves this problem by
enabling system administrators to set up a table that links
Helix Server
file types with filename specifications. If an entry in the typemap table
matches a file being added, it overrides the file type that would
otherwise be assigned by the
Helix Server
application. For example, to treat all PDF and RTF files as
binary
, use p4 typemap
to modify the
typemap table as follows:
Typemap: binary //....pdf binary //....rtf
The first three periods ("...
") in the specification are a
Helix Server
wildcard specifying that all files beneath the root directory are to be
included in the mapping. The fourth period and the file extension specify
that the specification applies to files ending in .pdf
(or
.rtf
).
The following table lists recommended Helix Server file types and modifiers for common file extensions.
File type | Helix Server file type | Description |
---|---|---|
|
|
Active server page file |
|
|
Video for Windows file |
|
|
Windows bitmap file |
|
|
Btrieve database file |
|
|
Conference link file |
|
|
Cascading style sheet file |
|
|
Microsoft Word document |
|
|
Microsoft Word template |
|
|
Export file (Microsoft Visual C++) |
|
|
GIF graphic file |
|
|
Gzip compressed file |
|
|
HTML file |
|
|
HTML file |
|
|
Icon file |
|
|
Active Server include file |
|
|
Initial application settings file |
|
|
JPEG graphic file |
|
|
JavaScript language source code file |
|
|
Library file (several programming languages) |
|
|
Log file |
|
|
MPEG video file |
|
|
Adobe PDF file |
|
|
Sybase Power Designer file |
|
|
Microsoft PowerPoint file |
|
|
Unity3D file |
|
|
Microsoft Excel file |
Use the following p4 typemap
table to map all of the
file extensions to the
Helix Server
file types recommended in the preceding table.
# Perforce File Type Mapping Specifications. # # TypeMap: a list of filetype mappings; one per line. # Each line has two elements: # Filetype: The filetype to use on 'p4 add'. # Path: File pattern which will use this filetype. # See 'p4 help typemap' for more information. TypeMap: text //....asp binary+F //....avi binary //....bmp binary //....btr text //....cnf text //....css binary //....doc binary //....dot binary+w //....exp binary+F //....gif binary+F //....gz text //....htm text //....html binary //....ico text //....inc text+w //....ini binary //....jpg text //....js binary+w //....lib text+w //....log binary+F //....mpg binary //....pdf text+w //....pdm binary //....ppt binary //....xls
If a file type requires the use of more than one file type modifier,
specify the modifiers consecutively. For example,
binary+lFS10
refers to a binary
file with
exclusive-open (l
), stored in full (F
) rather
than compressed, and for which only the most recent ten revisions are
stored (S10
).
For more information, see the p4 typemap
page in the
Helix Core Command-Line (P4) Reference.