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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFile.ResultFile module result object
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LocalCall<String>chmod(String path, String mode)Set the mode of a filestatic LocalCall<String>chown(String path, String user, String group)Chown a filestatic LocalCall<Boolean>copy(String src, String dst, boolean recurse, boolean removeExisting)Copy a file or directory from src to dststatic LocalCall<Boolean>directoryExists(String path)Tests to see if path is a valid directorystatic LocalCall<Boolean>fileExists(String path)Tests to see if path is a valid filestatic LocalCall<String>getHash(String path)Get the hash sum of a filestatic LocalCall<String>getHash(String path, HashType form)Get the hash sum of a filestatic LocalCall<String>getHash(String path, HashType form, long chunkSize)Get the hash sum of a filestatic LocalCall<String>getMode(String path, boolean followSymlinks)Return the mode of a filestatic LocalCall<String>getUid(String path, boolean followSymlinks)Return the id of the user that owns a given filestatic LocalCall<String>getUser(String path, boolean followSymlinks)Return the user that owns a given filestatic LocalCall<Boolean>isLink(String path)Check if the path is a symbolic linkstatic LocalCall<String>mkdir(String path)Ensures that a directory is availablestatic LocalCall<String>mkdir(String path, String mode)Ensures that a directory is availablestatic LocalCall<String>mkdir(String path, String user, String group)Ensures that a directory is availablestatic LocalCall<String>mkdir(String path, String user, String group, String mode)Ensures that a directory is availablestatic LocalCall<File.Result>move(String src, String dst)Move a file or directory from src to dststatic LocalCall<List<String>>readdir(String path)Returns a list containing the contents of a directorystatic LocalCall<Boolean>remove(String path)Remove a filestatic LocalCall<Boolean>rmdir(String path)Removes the specified directorystatic LocalCall<Boolean>symlink(String src, String path)Create a symbolic link (symlink, soft link) to a file
-
-
-
Method Detail
-
chown
public static LocalCall<String> chown(String path, String user, 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<String> chmod(String path, 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<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 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(String src, 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<Boolean> remove(String path)
Remove a file- Parameters:
path- File path to remove- Returns:
- The
LocalCallobject to make the call
-
getHash
public static LocalCall<String> getHash(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<String> getHash(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<String> getHash(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
-
directoryExists
public static LocalCall<Boolean> directoryExists(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<Boolean> fileExists(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<String> getMode(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<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 ownerfollowSymlinks- Indicated if symlinks should be followed- Returns:
- The
LocalCallobject 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 ownerfollowSymlinks- Indicated if symlinks should be followed- Returns:
- The
LocalCallobject 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
LocalCallobject to make the call
-
mkdir
public static LocalCall<String> mkdir(String path, 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<String> mkdir(String path, String user, 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<String> mkdir(String path, String user, String group, 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
-
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
LocalCallobject to make the call
-
rmdir
public static LocalCall<Boolean> rmdir(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<Boolean> isLink(String path)
Check if the path is a symbolic link- Parameters:
path- Path to file or directory- Returns:
- The
LocalCallobject to make the call
-
-