Class ProcessPipeUtils


  • public class ProcessPipeUtils
    extends Object
    Utility functions to create file and input stream transform based on system calls InputStreams passed as arguments to the various processors are considered to be owned by the processors. Hence, the processors are in charge of closing them. The client code is in charge of closing InputStreams returned by the processors. TODO Enhance the FileCreation objects such that they expose a future for when the process started modifying the file.
    Author:
    raven
    • Constructor Detail

      • ProcessPipeUtils

        public ProcessPipeUtils()
    • Method Detail

      • createPipedTransformer

        public static java.util.function.Function<InputStream,​InputStream> createPipedTransformer​(java.util.function.BiConsumer<InputStream,​OutputStream> action)
        TODO Move this method elsewhere as it does not make use of a process Transformation using a piped input/outputstream createPipedTransform((in, out) -> { for(item : () -> readItems(in)) { write(item); } )
        Parameters:
        action -
        Returns:
      • startThreadedCopy

        public static Thread startThreadedCopy​(InputStream from,
                                               OutputStream to,
                                               java.util.function.Consumer<Exception> failureCallback)
        Create a new thread to copy from source to target TODO Closing the target silently terminate the thread and associated resources (such as a system process) Closing the input stream should not happen though as it is considered to be owned by the copy process
        Parameters:
        from -
        to -
        Returns:
      • mapPathToStream

        public static PathToStream mapPathToStream​(java.util.function.Function<Path,​String[]> cmdBuilder)
      • mapPathToPath

        public static java.util.function.BiFunction<Path,​Path,​FileCreation> mapPathToPath​(java.util.function.BiFunction<Path,​Path,​String[]> cmdBuilder)