Class File

  • Direct Known Subclasses:
    Directory, RegularFile, SymbolicLink

    public abstract class File
    extends java.lang.Object
    An abstract class denoting a file entry in a package with all relevant attributes.

    A file does not necessarily mean a regular file, it could be for example a directory or a device file.

    Author:
    Mikolaj Izdebski
    • Constructor Summary

      Constructors 
      Constructor Description
      File​(java.nio.file.Path targetPath)
      Create a file object with specified path and default access mode of 0644.
      File​(java.nio.file.Path targetPath, int accessMode)
      Create a file object with specified path and access mode.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object rhs)  
      int getAccessMode()
      Get Unix access mode for this file.
      java.lang.String getDescriptor()
      Get descriptor string for given file.
      protected java.lang.String getDescriptorExtra()
      Get additional file attributes to be added to file descriptor.
      java.nio.file.Path getTargetPath()
      Return path to target file.
      int hashCode()  
      void install​(java.nio.file.Path installRoot)
      Install file into specified root directory.
      protected abstract void installContents​(java.nio.file.Path targetAbsolutePath)
      Install the file into specified location.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • File

        public File​(java.nio.file.Path targetPath)
        Create a file object with specified path and default access mode of 0644.
        Parameters:
        targetPath - file path, relative to installation root
      • File

        public File​(java.nio.file.Path targetPath,
                    int accessMode)
        Create a file object with specified path and access mode.
        Parameters:
        targetPath - file path, relative to installation root
        accessMode - Unix access mode of the file (must be an integer in range from 0 to 0777)
    • Method Detail

      • installContents

        protected abstract void installContents​(java.nio.file.Path targetAbsolutePath)
                                         throws java.io.IOException
        Install the file into specified location.

        Implementations of this method can assume that all parent directory of target file already exists. Access mode of target file doesn't have to be set as it will be manipulated with other means.

        Parameters:
        targetAbsolutePath - absolute path to the target file
        Throws:
        java.io.IOException
      • getDescriptorExtra

        protected java.lang.String getDescriptorExtra()
        Get additional file attributes to be added to file descriptor.

        By default there are no extra attributes, but subclasses can override this method and specify it.

        Returns:
        extra descriptor data (can be null)
      • getTargetPath

        public java.nio.file.Path getTargetPath()
        Return path to target file. Returned path is always relative to buildroot (never absolute).
        Returns:
        file target path (never null)
      • getAccessMode

        public int getAccessMode()
        Get Unix access mode for this file.
        Returns:
        Unix access mode (an integer in range from 0 to 0777)
      • install

        public void install​(java.nio.file.Path installRoot)
                     throws java.io.IOException
        Install file into specified root directory.
        Parameters:
        installRoot -
        Throws:
        java.io.IOException
      • getDescriptor

        public java.lang.String getDescriptor()
        Get descriptor string for given file.

        Descriptor is a line containing file path and some attributes. In other words, descriptor is a single line from .mfiles describing the file.

        Returns:
        descriptor string
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object rhs)
        Overrides:
        equals in class java.lang.Object