Class File

java.lang.Object
com.suse.salt.netapi.calls.modules.File

public class File extends Object
Basic operations on files and directories on minions
  • Constructor Details

    • File

      private File()
  • Method Details

    • chown

      public static LocalCall<String> chown(String path, String user, 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<String> chmod(String path, 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<Boolean> copy(String src, 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(String src, 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<Boolean> remove(String path)
      Remove a file
      Parameters:
      path - File path to remove
      Returns:
      The LocalCall object to make the call
    • getHash

      public static LocalCall<String> getHash(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<String> getHash(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<String> getHash(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<String> getHash(String path, Optional<HashType> form, Optional<Long> chunkSize)
    • directoryExists

      public static LocalCall<Boolean> directoryExists(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<Boolean> fileExists(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<String> getMode(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<String> getUid(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<String> getUser(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<String> mkdir(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<String> mkdir(String path, 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<String> mkdir(String path, String user, 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<String> mkdir(String path, String user, String group, 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<String> mkdir(String path, Optional<String> user, Optional<String> group, Optional<String> mode)
    • readdir

      public static LocalCall<List<String>> readdir(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<Boolean> rmdir(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<Boolean> isLink(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<Boolean> symlink(String src, 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