Enum RpcPerforceFileType
- java.lang.Object
-
- java.lang.Enum<RpcPerforceFileType>
-
- com.perforce.p4java.impl.mapbased.rpc.sys.RpcPerforceFileType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<RpcPerforceFileType>
public enum RpcPerforceFileType extends java.lang.Enum<RpcPerforceFileType>
Definitions for Perforce client and server file types.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 apple
In 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.).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RpcPerforceFileType.RpcServerTypeStringSpec
-
Enum Constant Summary
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TRACE_PREFIX
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Enum Constant Detail
-
FST_TEXT
public static final RpcPerforceFileType FST_TEXT
-
FST_BINARY
public static final RpcPerforceFileType FST_BINARY
-
FST_GZIP
public static final RpcPerforceFileType FST_GZIP
-
FST_DIRECTORY
public static final RpcPerforceFileType FST_DIRECTORY
-
FST_SYMLINK
public static final RpcPerforceFileType FST_SYMLINK
-
FST_RESOURCE
public static final RpcPerforceFileType FST_RESOURCE
-
FST_SPECIAL
public static final RpcPerforceFileType FST_SPECIAL
-
FST_MISSING
public static final RpcPerforceFileType FST_MISSING
-
FST_CANTTELL
public static final RpcPerforceFileType FST_CANTTELL
-
FST_EMPTY
public static final RpcPerforceFileType FST_EMPTY
-
FST_UNICODE
public static final RpcPerforceFileType FST_UNICODE
-
FST_GUNZIP
public static final RpcPerforceFileType FST_GUNZIP
-
FST_UTF8
public static final RpcPerforceFileType FST_UTF8
-
FST_UTF16
public static final RpcPerforceFileType FST_UTF16
-
FST_TEXT_GUNZIP
public static final RpcPerforceFileType FST_TEXT_GUNZIP
-
FST_BINARY_GUNZIP
public static final RpcPerforceFileType FST_BINARY_GUNZIP
-
FST_XTEXT_GUNZIP
public static final RpcPerforceFileType FST_XTEXT_GUNZIP
-
FST_XBINARY_GUNZIP
public static final RpcPerforceFileType FST_XBINARY_GUNZIP
-
FST_SYMLINK_GUNZIP
public static final RpcPerforceFileType FST_SYMLINK_GUNZIP
-
FST_RESOURCE_GUNZIP
public static final RpcPerforceFileType FST_RESOURCE_GUNZIP
-
FST_XSYMLINK_GUNZIP
public static final RpcPerforceFileType FST_XSYMLINK_GUNZIP
-
FST_XRESOURCE_GUNZIP
public static final RpcPerforceFileType FST_XRESOURCE_GUNZIP
-
FST_UNICODE_GUNZIP
public static final RpcPerforceFileType FST_UNICODE_GUNZIP
-
FST_RTEXT_GUNZIP
public static final RpcPerforceFileType FST_RTEXT_GUNZIP
-
FST_XUNICODE_GUNZIP
public static final RpcPerforceFileType FST_XUNICODE_GUNZIP
-
FST_XRTEXT_GUNZIP
public static final RpcPerforceFileType FST_XRTEXT_GUNZIP
-
FST_APPLETEXT_GUNZIP
public static final RpcPerforceFileType FST_APPLETEXT_GUNZIP
-
FST_APPLEFILE_GUNZIP
public static final RpcPerforceFileType FST_APPLEFILE_GUNZIP
-
FST_XAPPLETEXT_GUNZIP
public static final RpcPerforceFileType FST_XAPPLETEXT_GUNZIP
-
FST_XAPPLEFILE_GUNZIP
public static final RpcPerforceFileType FST_XAPPLEFILE_GUNZIP
-
FST_UTF8_GUNZIP
public static final RpcPerforceFileType FST_UTF8_GUNZIP
-
FST_XUTF8_GUNZIP
public static final RpcPerforceFileType FST_XUTF8_GUNZIP
-
FST_UTF16_GUNZIP
public static final RpcPerforceFileType FST_UTF16_GUNZIP
-
FST_XUTF16_GUNZIP
public static final RpcPerforceFileType FST_XUTF16_GUNZIP
-
FST_ATEXT
public static final RpcPerforceFileType FST_ATEXT
-
FST_XTEXT
public static final RpcPerforceFileType FST_XTEXT
-
FST_RTEXT
public static final RpcPerforceFileType FST_RTEXT
-
FST_RXTEXT
public static final RpcPerforceFileType FST_RXTEXT
-
FST_CBINARY
public static final RpcPerforceFileType FST_CBINARY
-
FST_XBINARY
public static final RpcPerforceFileType FST_XBINARY
-
FST_XSYMLINK
public static final RpcPerforceFileType FST_XSYMLINK
-
FST_XRESOURCE
public static final RpcPerforceFileType FST_XRESOURCE
-
FST_APPLETEXT
public static final RpcPerforceFileType FST_APPLETEXT
-
FST_APPLEFILE
public static final RpcPerforceFileType FST_APPLEFILE
-
FST_XAPPLEFILE
public static final RpcPerforceFileType FST_XAPPLEFILE
-
FST_XAPPLETEXT
public static final RpcPerforceFileType FST_XAPPLETEXT
-
FST_XUNICODE
public static final RpcPerforceFileType FST_XUNICODE
-
FST_XRTEXT
public static final RpcPerforceFileType FST_XRTEXT
-
FST_XUTF8
public static final RpcPerforceFileType FST_XUTF8
-
FST_XUTF16
public static final RpcPerforceFileType FST_XUTF16
-
FST_XGUNZIP
public static final RpcPerforceFileType FST_XGUNZIP
-
FST_RCS
public static final RpcPerforceFileType FST_RCS
-
-
Field Detail
-
TRACE_PREFIX
public static final java.lang.String TRACE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static RpcPerforceFileType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RpcPerforceFileType c : RpcPerforceFileType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RpcPerforceFileType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
decodeFromServerString
public static RpcPerforceFileType decodeFromServerString(java.lang.String str)
Decode the file type from the string sent by the server. This is (usually) a three-character hex encoding, e.g. "101" or "01D".- Parameters:
str
- string- Returns:
- type
-
isExecutable
public boolean isExecutable()
Checking for executable file types - excluding "forbidden" types.- Returns:
- true, if known type
-
isCompressed
public boolean isCompressed()
Checking for compressed file types - excluding "forbidden" types.- Returns:
- true, if known type
-
inferFileType
public 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. This is an arbitrarily complex operation, and may involve reading in the first few bytes of a file to see what the contents say about the type.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.
- Parameters:
file
- filescanSize
- scanSizeisUnicodeServer
- isUnicodeServerclientCharset
- clientCharset- Returns:
- type
-
getServerFileTypeString
public 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.- Parameters:
clientPath
- clientPathoverSize
- overSizefileType
- fileTypeforceType
- forceTypexlevel
- xlevel- Returns:
- RpcServerTypeStringSpec spec
-
isProbablySymLink
public 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. This is just a hack that's here until I can do something better with native code...- Parameters:
file
- file- Returns:
- true, if symlink
-
isKnownCBinary
public 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). Typically things like JPEGs and GIFs, etc.- Parameters:
bytes
- bytesbytesRead
- bytesRead- Returns:
- if known
-
getBinaryMagicNumberTable
public static byte[][] getBinaryMagicNumberTable()
-
-