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 p4 typemap feature. For example, Postscript files are textual in format, but because diffs between revisions are not useful and diffing huge Postscript files can adversely affect server performance, you can use p4 typemap to specify that Postscript files be stored as type binary, which are not diffed by default.
If you want to tell the Perforce server to regard all PDF files in the root directory as binary, for example, you would enter the following command on the command line:
The above command opens the typemap table. Modify the table to include the following line:
All PDF files under the root directory are subsequently treated as binary files by the Perforce server.
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.
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 a 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|
|.inc||text||Active Server include file|
|.ini||text+w||Initial application settings file|
|.jpg||binary||JPEG graphic file|
|.lib||binary+w||Library file (several programming languages)|
|.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|
|.war||binary||Web Application Archive|
|.rar||binary||Resource Adapter Archive|
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.