Class File


  • public class File
    extends java.lang.Object
    Basic operations on files and directories on minions
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  File.Result
      File module result object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private File()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static LocalCall<java.lang.String> chmod​(java.lang.String path, java.lang.String mode)
      Set the mode of a file
      static LocalCall<java.lang.String> chown​(java.lang.String path, java.lang.String user, java.lang.String group)
      Chown a file
      static LocalCall<java.lang.Boolean> copy​(java.lang.String src, java.lang.String dst, boolean recurse, boolean removeExisting)
      Copy a file or directory from src to dst
      static LocalCall<java.lang.Boolean> directoryExists​(java.lang.String path)
      Tests to see if path is a valid directory
      static LocalCall<java.lang.Boolean> fileExists​(java.lang.String path)
      Tests to see if path is a valid file
      static LocalCall<java.lang.String> getHash​(java.lang.String path)
      Get the hash sum of a file
      static LocalCall<java.lang.String> getHash​(java.lang.String path, HashType form)
      Get the hash sum of a file
      static LocalCall<java.lang.String> getHash​(java.lang.String path, HashType form, long chunkSize)
      Get the hash sum of a file
      private static LocalCall<java.lang.String> getHash​(java.lang.String path, java.util.Optional<HashType> form, java.util.Optional<java.lang.Long> chunkSize)  
      static LocalCall<java.lang.String> getMode​(java.lang.String path, boolean followSymlinks)
      Return the mode of a file
      static LocalCall<java.lang.String> getUid​(java.lang.String path, boolean followSymlinks)
      Return the id of the user that owns a given file
      static LocalCall<java.lang.String> getUser​(java.lang.String path, boolean followSymlinks)
      Return the user that owns a given file
      static LocalCall<java.lang.Boolean> isLink​(java.lang.String path)
      Check if the path is a symbolic link
      static LocalCall<java.lang.String> mkdir​(java.lang.String path)
      Ensures that a directory is available
      static LocalCall<java.lang.String> mkdir​(java.lang.String path, java.lang.String mode)
      Ensures that a directory is available
      static LocalCall<java.lang.String> mkdir​(java.lang.String path, java.lang.String user, java.lang.String group)
      Ensures that a directory is available
      static LocalCall<java.lang.String> mkdir​(java.lang.String path, java.lang.String user, java.lang.String group, java.lang.String mode)
      Ensures that a directory is available
      private static LocalCall<java.lang.String> mkdir​(java.lang.String path, java.util.Optional<java.lang.String> user, java.util.Optional<java.lang.String> group, java.util.Optional<java.lang.String> mode)  
      static LocalCall<File.Result> move​(java.lang.String src, java.lang.String dst)
      Move a file or directory from src to dst
      static LocalCall<java.util.List<java.lang.String>> readdir​(java.lang.String path)
      Returns a list containing the contents of a directory
      static LocalCall<java.lang.Boolean> remove​(java.lang.String path)
      Remove a file
      static LocalCall<java.lang.Boolean> rmdir​(java.lang.String path)
      Removes the specified directory
      static LocalCall<java.lang.Boolean> symlink​(java.lang.String src, java.lang.String path)
      Create a symbolic link (symlink, soft link) to a file
      • Methods inherited from class java.lang.Object

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

      • File

        private File()
    • Method Detail

      • chown

        public static LocalCall<java.lang.String> chown​(java.lang.String path,
                                                        java.lang.String user,
                                                        java.lang.String group)
        Chown a file
        Parameters:
        path - Path to the file or directory
        user - User owner
        group - Group owner
        Returns:
        The LocalCall object to make the call
      • chmod

        public static LocalCall<java.lang.String> chmod​(java.lang.String path,
                                                        java.lang.String mode)
        Set the mode of a file
        Parameters:
        path - File or directory of which to set the mode
        mode - Mode to set the path to
        Returns:
        The LocalCall object to make the call
      • copy

        public static LocalCall<java.lang.Boolean> copy​(java.lang.String src,
                                                        java.lang.String dst,
                                                        boolean recurse,
                                                        boolean removeExisting)
        Copy a file or directory from src to dst
        Parameters:
        src - File or directory to copy
        dst - Destination path
        recurse - Recurse flag
        removeExisting - If true, all files in the target directory are removed, and then the files are copied from the source
        Returns:
        The LocalCall object to make the call
      • move

        public static LocalCall<File.Result> move​(java.lang.String src,
                                                  java.lang.String dst)
        Move a file or directory from src to dst
        Parameters:
        src - File or directory to copy
        dst - Destination path
        Returns:
        The LocalCall object to make the call
      • remove

        public static LocalCall<java.lang.Boolean> remove​(java.lang.String path)
        Remove a file
        Parameters:
        path - File path to remove
        Returns:
        The LocalCall object to make the call
      • getHash

        public static LocalCall<java.lang.String> getHash​(java.lang.String path)
        Get the hash sum of a file

        SHA256 algorithm is used by default

        Parameters:
        path - Path to the file or directory
        Returns:
        The LocalCall object to make the call
      • getHash

        public static LocalCall<java.lang.String> getHash​(java.lang.String path,
                                                          HashType form)
        Get the hash sum of a file
        Parameters:
        path - Path to the file or directory
        form - Desired sum format
        Returns:
        The LocalCall object to make the call
      • getHash

        public static LocalCall<java.lang.String> getHash​(java.lang.String path,
                                                          HashType form,
                                                          long chunkSize)
        Get the hash sum of a file
        Parameters:
        path - Path to the file or directory
        form - Desired sum format
        chunkSize - Amount to sum at once
        Returns:
        The LocalCall object to make the call
      • getHash

        private static LocalCall<java.lang.String> getHash​(java.lang.String path,
                                                           java.util.Optional<HashType> form,
                                                           java.util.Optional<java.lang.Long> chunkSize)
      • directoryExists

        public static LocalCall<java.lang.Boolean> directoryExists​(java.lang.String path)
        Tests to see if path is a valid directory
        Parameters:
        path - Path to directory
        Returns:
        The LocalCall object to make the call
      • fileExists

        public static LocalCall<java.lang.Boolean> fileExists​(java.lang.String path)
        Tests to see if path is a valid file
        Parameters:
        path - Path to file
        Returns:
        The LocalCall object to make the call
      • getMode

        public static LocalCall<java.lang.String> getMode​(java.lang.String path,
                                                          boolean followSymlinks)
        Return the mode of a file
        Parameters:
        path - File or directory of which to get the mode
        followSymlinks - Indicated if symlinks should be followed
        Returns:
        The LocalCall object to make the call
      • getUid

        public static LocalCall<java.lang.String> getUid​(java.lang.String path,
                                                         boolean followSymlinks)
        Return the id of the user that owns a given file
        Parameters:
        path - File or directory of which to get the uid owner
        followSymlinks - Indicated if symlinks should be followed
        Returns:
        The LocalCall object to make the call
      • getUser

        public static LocalCall<java.lang.String> getUser​(java.lang.String path,
                                                          boolean followSymlinks)
        Return the user that owns a given file
        Parameters:
        path - File or directory of which to get the user owner
        followSymlinks - Indicated if symlinks should be followed
        Returns:
        The LocalCall object to make the call
      • mkdir

        public static LocalCall<java.lang.String> mkdir​(java.lang.String path)
        Ensures that a directory is available
        Parameters:
        path - Path to directory
        Returns:
        The LocalCall object to make the call
      • mkdir

        public static LocalCall<java.lang.String> mkdir​(java.lang.String path,
                                                        java.lang.String mode)
        Ensures that a directory is available
        Parameters:
        path - Path to directory
        mode - Mode for the newly created directory
        Returns:
        The LocalCall object to make the call
      • mkdir

        public static LocalCall<java.lang.String> mkdir​(java.lang.String path,
                                                        java.lang.String user,
                                                        java.lang.String group)
        Ensures that a directory is available
        Parameters:
        path - Path to directory
        user - Owner user
        group - Owner group
        Returns:
        The LocalCall object to make the call
      • mkdir

        public static LocalCall<java.lang.String> mkdir​(java.lang.String path,
                                                        java.lang.String user,
                                                        java.lang.String group,
                                                        java.lang.String mode)
        Ensures that a directory is available
        Parameters:
        path - Path to directory
        user - Owner user
        group - Owner group
        mode - Mode for the newly created directory
        Returns:
        The LocalCall object to make the call
      • mkdir

        private static LocalCall<java.lang.String> mkdir​(java.lang.String path,
                                                         java.util.Optional<java.lang.String> user,
                                                         java.util.Optional<java.lang.String> group,
                                                         java.util.Optional<java.lang.String> mode)
      • readdir

        public static LocalCall<java.util.List<java.lang.String>> readdir​(java.lang.String path)
        Returns a list containing the contents of a directory
        Parameters:
        path - Path to directory
        Returns:
        The LocalCall object to make the call
      • rmdir

        public static LocalCall<java.lang.Boolean> rmdir​(java.lang.String path)
        Removes the specified directory

        Fails if the directory is not empty

        Parameters:
        path - Path to directory
        Returns:
        The LocalCall object to make the call
      • isLink

        public static LocalCall<java.lang.Boolean> isLink​(java.lang.String path)
        Check if the path is a symbolic link
        Parameters:
        path - Path to file or directory
        Returns:
        The LocalCall object to make the call
      • symlink

        public static LocalCall<java.lang.Boolean> symlink​(java.lang.String src,
                                                           java.lang.String path)
        Create a symbolic link (symlink, soft link) to a file
        Parameters:
        src - Path to file or directory
        path - Path to symbolic link
        Returns:
        The LocalCall object to make the call