Class File
- java.lang.Object
-
- com.suse.salt.netapi.calls.modules.File
-
public class File extends java.lang.ObjectBasic operations on files and directories on minions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFile.ResultFile module result object
-
Constructor Summary
Constructors Modifier Constructor Description privateFile()
-
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 filestatic LocalCall<java.lang.String>chown(java.lang.String path, java.lang.String user, java.lang.String group)Chown a filestatic 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 dststatic LocalCall<java.lang.Boolean>directoryExists(java.lang.String path)Tests to see if path is a valid directorystatic LocalCall<java.lang.Boolean>fileExists(java.lang.String path)Tests to see if path is a valid filestatic LocalCall<java.lang.String>getHash(java.lang.String path)Get the hash sum of a filestatic LocalCall<java.lang.String>getHash(java.lang.String path, HashType form)Get the hash sum of a filestatic LocalCall<java.lang.String>getHash(java.lang.String path, HashType form, long chunkSize)Get the hash sum of a fileprivate 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 filestatic LocalCall<java.lang.String>getUid(java.lang.String path, boolean followSymlinks)Return the id of the user that owns a given filestatic LocalCall<java.lang.String>getUser(java.lang.String path, boolean followSymlinks)Return the user that owns a given filestatic LocalCall<java.lang.Boolean>isLink(java.lang.String path)Check if the path is a symbolic linkstatic LocalCall<java.lang.String>mkdir(java.lang.String path)Ensures that a directory is availablestatic LocalCall<java.lang.String>mkdir(java.lang.String path, java.lang.String mode)Ensures that a directory is availablestatic LocalCall<java.lang.String>mkdir(java.lang.String path, java.lang.String user, java.lang.String group)Ensures that a directory is availablestatic 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 availableprivate 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 dststatic LocalCall<java.util.List<java.lang.String>>readdir(java.lang.String path)Returns a list containing the contents of a directorystatic LocalCall<java.lang.Boolean>remove(java.lang.String path)Remove a filestatic LocalCall<java.lang.Boolean>rmdir(java.lang.String path)Removes the specified directorystatic LocalCall<java.lang.Boolean>symlink(java.lang.String src, java.lang.String path)Create a symbolic link (symlink, soft link) to a 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 directoryuser- User ownergroup- Group owner- Returns:
- The
LocalCallobject 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 modemode- Mode to set the path to- Returns:
- The
LocalCallobject 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 copydst- Destination pathrecurse- Recurse flagremoveExisting- If true, all files in the target directory are removed, and then the files are copied from the source- Returns:
- The
LocalCallobject 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 copydst- Destination path- Returns:
- The
LocalCallobject 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
LocalCallobject to make the call
-
getHash
public static LocalCall<java.lang.String> getHash(java.lang.String path)
Get the hash sum of a fileSHA256 algorithm is used by default
- Parameters:
path- Path to the file or directory- Returns:
- The
LocalCallobject 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 directoryform- Desired sum format- Returns:
- The
LocalCallobject 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 directoryform- Desired sum formatchunkSize- Amount to sum at once- Returns:
- The
LocalCallobject 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
LocalCallobject 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
LocalCallobject 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 modefollowSymlinks- Indicated if symlinks should be followed- Returns:
- The
LocalCallobject 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 ownerfollowSymlinks- Indicated if symlinks should be followed- Returns:
- The
LocalCallobject 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 ownerfollowSymlinks- Indicated if symlinks should be followed- Returns:
- The
LocalCallobject 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
LocalCallobject 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 directorymode- Mode for the newly created directory- Returns:
- The
LocalCallobject 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 directoryuser- Owner usergroup- Owner group- Returns:
- The
LocalCallobject 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 directoryuser- Owner usergroup- Owner groupmode- Mode for the newly created directory- Returns:
- The
LocalCallobject 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
LocalCallobject to make the call
-
rmdir
public static LocalCall<java.lang.Boolean> rmdir(java.lang.String path)
Removes the specified directoryFails if the directory is not empty
- Parameters:
path- Path to directory- Returns:
- The
LocalCallobject 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
LocalCallobject to make the call
-
-