public enum RpcPerforceFileType extends java.lang.Enum<RpcPerforceFileType>
Perforce defines a surprising variety of basic file types and associated modifiers that determine things like how to send and receive file contents between the client and the server (UTF-8 vs UTF-16, compressed binary vs. uncompressed binary, plain old "text", etc.) and how to interpret file metadata. These types and the associated panoply of methods, etc., are mostly used in the clientCheckFile, clientOpen, clientClose, clientWrite, etc. methods on the various client function classes.
A file's type is stored in the server for all known files, (see e.g. "p4 help typemap" and "p4 help filetypes"), and in most cases we simply accept what we're given if we can cope with that type (there are some types we don't process at all here -- see below). What sort of file types a server (as opposed to the client) knows about and can process depends on the server's xlevel protocol variable:
- xfiles unset: return text, binary. - xfiles >= 0: also return xtext, xbinary. - xfiles >= 1: also return symlink. - xfiles >= 2; also return resource (mac resource file). - xfiles >= 3; also return ubinary - xfiles >= 4; also return appleIn general, the client has to honour the server's xlevel capabilities, so the client may have to do a bit of work to get things right here.
Unfortunately, in some cases it's very difficult to know what Perforce type a file should be, and there's a bunch of digging around that must be done to intuit the proper type for files the server doesn't (yet) know about.
Also somewhat unfortunately, the file type is encoded quite differently depending on whether it's coming from the server (usually encoded as a string representation of hex numbers) or going to the server (where it's usually done as plain old "text" or "ubinary", etc.).
Modifier and Type | Class and Description |
---|---|
static class |
RpcPerforceFileType.RpcServerTypeStringSpec |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TRACE_PREFIX |
Modifier and Type | Method and Description |
---|---|
static RpcPerforceFileType |
decodeFromServerString(java.lang.String str)
Decode the file type from the string sent by the server.
|
static byte[][] |
getBinaryMagicNumberTable() |
static RpcPerforceFileType.RpcServerTypeStringSpec |
getServerFileTypeString(java.lang.String clientPath,
boolean overSize,
RpcPerforceFileType fileType,
java.lang.String forceType,
int xlevel)
Given a Perforce file type and the Perforce server's xfiles level (from the protocol
parameters), determine what server file type to send to the server to represent
the passed-in file type as a string, and / or what error or info message
to send to the user.
|
static RpcPerforceFileType |
inferFileType(java.io.File file,
int scanSize,
boolean isUnicodeServer,
java.nio.charset.Charset clientCharset)
Infer (or even intuit) the Perforce file type of the passed-in
Perforce file.
|
boolean |
isCompressed()
Checking for compressed file types - excluding "forbidden" types.
|
boolean |
isExecutable()
Checking for executable file types - excluding "forbidden" types.
|
static boolean |
isKnownCBinary(byte[] bytes,
int bytesRead)
Return true iff the file appears to start with some known
magic numbers that we interpret to mean the file is
pre-compressed binary (FST_CBINARY).
|
static boolean |
isProbablySymLink(java.io.File file)
Return true if there's some reason to believe this file is a
Unix or Linux symbolic link.
|
static RpcPerforceFileType |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static RpcPerforceFileType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RpcPerforceFileType FST_TEXT
public static final RpcPerforceFileType FST_BINARY
public static final RpcPerforceFileType FST_GZIP
public static final RpcPerforceFileType FST_DIRECTORY
public static final RpcPerforceFileType FST_SYMLINK
public static final RpcPerforceFileType FST_RESOURCE
public static final RpcPerforceFileType FST_SPECIAL
public static final RpcPerforceFileType FST_MISSING
public static final RpcPerforceFileType FST_CANTTELL
public static final RpcPerforceFileType FST_EMPTY
public static final RpcPerforceFileType FST_UNICODE
public static final RpcPerforceFileType FST_GUNZIP
public static final RpcPerforceFileType FST_UTF8
public static final RpcPerforceFileType FST_UTF16
public static final RpcPerforceFileType FST_TEXT_GUNZIP
public static final RpcPerforceFileType FST_BINARY_GUNZIP
public static final RpcPerforceFileType FST_XTEXT_GUNZIP
public static final RpcPerforceFileType FST_XBINARY_GUNZIP
public static final RpcPerforceFileType FST_SYMLINK_GUNZIP
public static final RpcPerforceFileType FST_RESOURCE_GUNZIP
public static final RpcPerforceFileType FST_XSYMLINK_GUNZIP
public static final RpcPerforceFileType FST_XRESOURCE_GUNZIP
public static final RpcPerforceFileType FST_UNICODE_GUNZIP
public static final RpcPerforceFileType FST_RTEXT_GUNZIP
public static final RpcPerforceFileType FST_XUNICODE_GUNZIP
public static final RpcPerforceFileType FST_XRTEXT_GUNZIP
public static final RpcPerforceFileType FST_APPLETEXT_GUNZIP
public static final RpcPerforceFileType FST_APPLEFILE_GUNZIP
public static final RpcPerforceFileType FST_XAPPLETEXT_GUNZIP
public static final RpcPerforceFileType FST_XAPPLEFILE_GUNZIP
public static final RpcPerforceFileType FST_UTF8_GUNZIP
public static final RpcPerforceFileType FST_XUTF8_GUNZIP
public static final RpcPerforceFileType FST_UTF16_GUNZIP
public static final RpcPerforceFileType FST_XUTF16_GUNZIP
public static final RpcPerforceFileType FST_ATEXT
public static final RpcPerforceFileType FST_XTEXT
public static final RpcPerforceFileType FST_RTEXT
public static final RpcPerforceFileType FST_RXTEXT
public static final RpcPerforceFileType FST_CBINARY
public static final RpcPerforceFileType FST_XBINARY
public static final RpcPerforceFileType FST_XSYMLINK
public static final RpcPerforceFileType FST_XRESOURCE
public static final RpcPerforceFileType FST_APPLETEXT
public static final RpcPerforceFileType FST_APPLEFILE
public static final RpcPerforceFileType FST_XAPPLEFILE
public static final RpcPerforceFileType FST_XAPPLETEXT
public static final RpcPerforceFileType FST_XUNICODE
public static final RpcPerforceFileType FST_XRTEXT
public static final RpcPerforceFileType FST_XUTF8
public static final RpcPerforceFileType FST_XUTF16
public static final RpcPerforceFileType FST_XGUNZIP
public static final RpcPerforceFileType FST_RCS
public static final java.lang.String TRACE_PREFIX
public static RpcPerforceFileType[] values()
for (RpcPerforceFileType c : RpcPerforceFileType.values()) System.out.println(c);
public static RpcPerforceFileType valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static RpcPerforceFileType decodeFromServerString(java.lang.String str)
str
- stringpublic boolean isExecutable()
public boolean isCompressed()
public static RpcPerforceFileType inferFileType(java.io.File file, int scanSize, boolean isUnicodeServer, java.nio.charset.Charset clientCharset)
Note that Java does not allow us to directly access most file metadata. This probably doesn't matter in most cases, but we do need to keep an eye on this -- HR.
file
- filescanSize
- scanSizeisUnicodeServer
- isUnicodeServerclientCharset
- clientCharsetpublic static RpcPerforceFileType.RpcServerTypeStringSpec getServerFileTypeString(java.lang.String clientPath, boolean overSize, RpcPerforceFileType fileType, java.lang.String forceType, int xlevel)
clientPath
- clientPathoverSize
- overSizefileType
- fileTypeforceType
- forceTypexlevel
- xlevelpublic static boolean isProbablySymLink(java.io.File file)
file
- filepublic static boolean isKnownCBinary(byte[] bytes, int bytesRead)
bytes
- bytesbytesRead
- bytesReadpublic static byte[][] getBinaryMagicNumberTable()