Class RegularFile


  • public class RegularFile
    extends File
    A regular file created installed in target package.

    The file can be installed either by coping an existing file (source file), or by writing provided contents.

    Author:
    Mikolaj Izdebski
    • Constructor Summary

      Constructors 
      Constructor Description
      RegularFile​(java.nio.file.Path targetPath, byte[] content)
      Create a regular file object, which contents will be populated from a byte array.
      RegularFile​(java.nio.file.Path targetPath, byte[] content, int accessMode)
      Create a regular file object, which contents will be populated from a byte array.
      RegularFile​(java.nio.file.Path targetPath, java.nio.file.Path sourcePath)
      Create a regular file object, which contents will be populated from a source file.
      RegularFile​(java.nio.file.Path targetPath, java.nio.file.Path sourcePath, int accessMode)
      Create a regular file object, which contents will be populated from a source file.
      RegularFile​(java.nio.file.Path targetPath, java.util.function.Supplier<byte[]> content)
      Create a regular file object, which contents will be populated from a byte array.
      RegularFile​(java.nio.file.Path targetPath, java.util.function.Supplier<byte[]> content, int accessMode)
      Create a regular file object, which contents will be populated from an input stream.
    • Constructor Detail

      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           java.nio.file.Path sourcePath)
        Create a regular file object, which contents will be populated from a source file. Target file will have default access mode (0644).
        Parameters:
        targetPath - file path, relative to installation root
        sourcePath - path to source file which will be copied to target path
      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           byte[] content)
        Create a regular file object, which contents will be populated from a byte array. Target file will have default access mode (0644).
        Parameters:
        targetPath - file path, relative to installation root
        content - array of bytes used to populate target file contents with
      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           java.util.function.Supplier<byte[]> content)
        Create a regular file object, which contents will be populated from a byte array. Target file will have default access mode (0644).
        Parameters:
        targetPath - file path, relative to installation root
        content - provider of array of bytes used to populate target file contents with
      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           java.nio.file.Path sourcePath,
                           int accessMode)
        Create a regular file object, which contents will be populated from a source file. Target file will have specified access mode.
        Parameters:
        targetPath - file path, relative to installation root
        sourcePath - path to source file which will be copied to target path
        accessMode - Unix access mode of the file (must be an integer in range from 0 to 0777)
      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           byte[] content,
                           int accessMode)
        Create a regular file object, which contents will be populated from a byte array. Target file will have specified access mode
        Parameters:
        targetPath - file path, relative to installation root
        content - array of bytes used to populate target file contents with
        accessMode - Unix access mode of the file (must be an integer in range from 0 to 0777)
      • RegularFile

        public RegularFile​(java.nio.file.Path targetPath,
                           java.util.function.Supplier<byte[]> content,
                           int accessMode)
        Create a regular file object, which contents will be populated from an input stream. Target file will have specified access mode
        Parameters:
        targetPath - file path, relative to installation root
        content - provider of array of bytes used to populate target file contents with
        accessMode - Unix access mode of the file (must be an integer in range from 0 to 0777)
    • Method Detail

      • installContents

        protected void installContents​(java.nio.file.Path targetPath)
                                throws java.io.IOException
        Description copied from class: File
        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.

        Specified by:
        installContents in class File
        Parameters:
        targetPath - absolute path to the target file
        Throws:
        java.io.IOException