Class FileMode


  • public abstract class FileMode
    extends Object
    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.

    • Method Detail

      • fromBits

        public static final FileMode fromBits​(int bits)
        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 this FileMode object.
        Parameters:
        modebits - a int.
        Returns:
        true if the mode bits represent the same mode as this object
      • copyTo

        public void copyTo​(OutputStream os)
                    throws IOException
        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 within buf for first digit.
      • 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

        public String toString()

        Format this mode as an octal string (for debugging only).

        Overrides:
        toString in class Object
      • getBits

        public int getBits()
        Get the mode bits as an integer.
        Returns:
        The mode bits as an integer.