Perforce File Type Options

Automatic type detection and file type usage recommendations

Info & Tags

Article #:
69
Created:
04/25/07
Modified:
01/09/08
Tags:
p4, p4d

PROBLEM

What Perforce filetypes should I use?

SOLUTION

Automatic File Type Detection

The Perforce Server identifies binary and text files based on whether it detects non-text characters in the first 8192 bytes of the file. Revisions of binary files are stored intact, but text files are diffed with the previous revision and only the changes (the "deltas") are stored.

Overriding Automatic File Type Detection

To override the Perforce file type detection logic when required, you can map operating system file types to Perforce file types using the Perforce typemap feature. For example, Postscript files are textual in format, but because (1) diffs between revisions are not useful and (2) diffing huge Postscript files can adversely affect server performance, you can use typemap to specify that Postscript files be stored as type binary, which are not diffed by default.

Basic File Typing Guidelines

Some basic guidelines for assigning file types:

  • If the file is textual and can be meaningfully diffed, store it as text.
    Example: README files.
     
  • If the file is textual but cannot be meaningfully diffed, choose binary or text+C
    Example: Large application-generated text files, Postscript files.


Recommendations

Acrobat (PDF) files

If you store PDF files in your depot, map them to the binary file type. PDF files have a textual header that can cause old (pre-2000.1) Perforce clients to identify them as text files.

Avoiding Accidental File Truncation

Some operating systems (notably Windows), interpret the Control-Z character (decimal 26 or hex 0x1a) as the end of file. To prevent inadvertent truncation, never store binary file content as text.

Very Large Text Files

Some programs generate very large text files. For example, certain chip design files can have file sizes up to 100MB. In general, storing text files over 2MB in RCS format is inefficient. Such large text files should generally be stored as compressed text (text+C) to avoid the overhead of computing deltas when editing files or accessing old revisions.

Common File Types

The following table lists some recommended Perforce file types and attributes for common file types.

Extension Perforce file type Description
.asp text Active server page file
.avi binary+F Video for Windows file
.bmp binary Windows bitmap file
.btr binary Btrieve database file
.cnf text Conference link file
.css text Cascading style sheet file
.doc binary Microsoft Word document
.dot binary Microsoft Word template
.exp binary+w Export file (Microsoft Visual C++)
.gif binary+F GIF graphic file
.htm text HTML file
.html text HTML file
.ico binary Icon file
.inc text Active Server include file
.ini text+w Initial application settings file
.jpg binary JPEG graphic file
.js text JavaScript language source code file
.lib binary+w Library file (several programming languages)
.log text+w Log file
.mpg binary+F MPEG video file
.pdf binary Adobe PDF file
.pdm text+w Sybase Power Designer file
.ppt binary Microsoft Powerpoint file
.xls binary+w Microsoft Excel file
.zip binary+F Compressed archive file

Additional Resources

For more information about Perforce file types, including handling of Unicode files, please refer to Appendix B of the P4 User's Guide.

For more information about using p4 typemap, refer to the Perforce Command Reference and the Perforce System Administrator's Guide.