Package org.eclipse.jgit.lib
Class FileMode
java.lang.Object
org.eclipse.jgit.lib.FileMode
Constants describing various file modes recognized by GIT.
GIT uses a subset of the available UNIX file permission bits. The
FileMode class provides access to constants defining the modes
actually used by GIT.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FileModeMode indicating an entry is an executable file.static final FileModeMode indicating an entry is a submodule commit in another repository.static final FileModeMode indicating an entry is missing during parallel walks.private final intprivate final intprivate final byte[]static final FileModeMode indicating an entry is a non-executable file.static final FileModeMode indicating an entry is a symbolic link.static final FileModeMode indicating an entry is a tree (aka directory).static final intBit pattern forTYPE_MASKmatchingREGULAR_FILE.static final intstatic final intMask to apply to a file mode to obtain its type bits.static final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyTo(byte[] buf, int ptr) Copy this mode as a sequence of octal US-ASCII bytes.voidcopyTo(OutputStream os) Copy this mode as a sequence of octal US-ASCII bytes.intCopy the number of bytes written bycopyTo(OutputStream).abstract booleanequals(int modebits) Test a file mode for equality with thisFileModeobject.static final FileModefromBits(int bits) Convert a set of mode bits into a FileMode enumerated value.intgetBits()Get the mode bits as an integer.intGet the object type that should appear for this type of mode.toString()
-
Field Details
-
TYPE_MASK
public static final int TYPE_MASKMask to apply to a file mode to obtain its type bits. -
TYPE_TREE
public static final int TYPE_TREE- See Also:
-
TYPE_SYMLINK
public static final int TYPE_SYMLINK- See Also:
-
TYPE_FILE
public static final int TYPE_FILEBit pattern forTYPE_MASKmatchingREGULAR_FILE.- See Also:
-
TYPE_GITLINK
public static final int TYPE_GITLINK- See Also:
-
TYPE_MISSING
public static final int TYPE_MISSING- See Also:
-
TREE
Mode indicating an entry is a tree (aka directory). -
SYMLINK
Mode indicating an entry is a symbolic link. -
REGULAR_FILE
Mode indicating an entry is a non-executable file. -
EXECUTABLE_FILE
Mode indicating an entry is an executable file. -
GITLINK
Mode indicating an entry is a submodule commit in another repository. -
MISSING
Mode indicating an entry is missing during parallel walks. -
octalBytes
private final byte[] octalBytes -
modeBits
private final int modeBits -
objectType
private final int objectType
-
-
Constructor Details
-
FileMode
private FileMode(int mode, int expType)
-
-
Method Details
-
fromBits
Convert a set of mode bits into a FileMode enumerated value.- Parameters:
bits- the mode bits the caller has somehow obtained.- Returns:
- the FileMode instance that represents the given bits.
-
equals
public abstract boolean equals(int modebits) Test a file mode for equality with thisFileModeobject.- Parameters:
modebits- a int.- Returns:
- true if the mode bits represent the same mode as this object
-
copyTo
Copy this mode as a sequence of octal US-ASCII bytes.The mode is copied as a sequence of octal digits using the US-ASCII character encoding. The sequence does not use a leading '0' prefix to indicate octal notation. This method is suitable for generation of a mode string within a GIT tree object.
- Parameters:
os- stream to copy the mode to.- Throws:
IOException- the stream encountered an error during the copy.
-
copyTo
public void copyTo(byte[] buf, int ptr) Copy this mode as a sequence of octal US-ASCII bytes. The mode is copied as a sequence of octal digits using the US-ASCII character encoding. The sequence does not use a leading '0' prefix to indicate octal notation. This method is suitable for generation of a mode string within a GIT tree object.- Parameters:
buf- buffer to copy the mode to.ptr- position withinbuffor first digit.
-
copyToLength
public int copyToLength()Copy the number of bytes written bycopyTo(OutputStream).- Returns:
- the number of bytes written by
copyTo(OutputStream).
-
getObjectType
public int getObjectType()Get the object type that should appear for this type of mode.See the object type constants in
Constants.- Returns:
- one of the well known object type constants.
-
toString
Format this mode as an octal string (for debugging only).
-
getBits
public int getBits()Get the mode bits as an integer.- Returns:
- The mode bits as an integer.
-