Package com.github.fracpete.rsync4j.core
Class Binaries
- java.lang.Object
-
- com.github.fracpete.rsync4j.core.Binaries
-
public class Binaries extends java.lang.ObjectHelper class for dealing with the rsync binaries. On Linux and OSX, rsync and ssh must be present.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.BooleanbinariesExtractedfor storing any previously extract binary.static java.lang.StringLIBRARIESprotected static java.util.logging.LoggerLOGGERfor logging.static java.lang.StringRESOURCE_DIRthe resource prefix.static java.lang.StringRSYNC4J_RSYNCthe environment variable for the rsync binary (Linux/Mac).static java.lang.StringRSYNC4J_SSHthe environment variable for the ssh binary (Linux/Mac).static java.lang.StringRSYNC4J_SSHKEYGENthe environment variable for the ssh-keygen binary (Linux/Mac).static java.lang.StringRSYNC4J_SSHPASSthe environment variable for the sshpass binary (Linux/Mac).protected static java.lang.StringrsyncBinarythe rsync binary.protected static java.lang.StringsshBinarythe ssh binary.protected static java.lang.StringsshkeygenBinarythe ssh-keygen binary.protected static java.lang.StringsshpassBinarythe sshpass binary.protected static booleansshpassBinaryPresentwhether the sshpass binary is present.static java.lang.StringWINDOWS_DIR_64the sub-directory for the windows 64bit binaries.static java.lang.StringWINDOWS_HOME_DIRthe windows environment variable for the rsyncj4 home directory.
-
Constructor Summary
Constructors Constructor Description Binaries()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringconvertPath(java.lang.String path)Converts the path into cygwin notation on Windows platform.protected static java.lang.StringcopyResourceTo(java.lang.String inDir, java.lang.String name, java.lang.String outDir)Copies the specified resource to the output directory.protected static voidextractBinaries()Extracts the binaries to the tmp directory.static intgetBitness()Returns the "bitness", ie 32 or 64 bit of the underlying OS.protected static java.util.List<java.lang.String>getLibraries()Returns the list of libraries to copy.protected static java.lang.StringgetWindowsDir()Returns the sub-directory for the Windows binaries, depending on the bitness.protected static java.lang.StringhomeDir()Returns the home directory to use for rsync4j.static java.lang.StringquotePath(java.lang.String path)Quotes the path if a single quote is in the name.static java.lang.StringquotePath(java.lang.String path, boolean force)Quotes the path if a single quote is in the name.static java.lang.StringrsyncBinary()Returns the rsync binary (if necessary extracts the binaries to the temp directory).static java.lang.StringsshBinary()Returns the ssh binary (if necessary extracts the binaries to the temp directory).static java.lang.StringsshkeygenBinary()Returns the ssh-keygen binary (if necessary extracts the binaries to the temp directory).static java.lang.StringsshpassBinary()Returns the sshpass binary (if necessary extracts the binaries to the temp directory).static booleansshpassBinaryPresent()Returns whether the sshpass binary is present (if necessary extracts the binaries to the temp directory).
-
-
-
Field Detail
-
RESOURCE_DIR
public static final java.lang.String RESOURCE_DIR
the resource prefix.- See Also:
- Constant Field Values
-
WINDOWS_DIR_64
public static final java.lang.String WINDOWS_DIR_64
the sub-directory for the windows 64bit binaries.- See Also:
- Constant Field Values
-
WINDOWS_HOME_DIR
public static final java.lang.String WINDOWS_HOME_DIR
the windows environment variable for the rsyncj4 home directory.- See Also:
- Constant Field Values
-
RSYNC4J_RSYNC
public static final java.lang.String RSYNC4J_RSYNC
the environment variable for the rsync binary (Linux/Mac).- See Also:
- Constant Field Values
-
RSYNC4J_SSH
public static final java.lang.String RSYNC4J_SSH
the environment variable for the ssh binary (Linux/Mac).- See Also:
- Constant Field Values
-
RSYNC4J_SSHPASS
public static final java.lang.String RSYNC4J_SSHPASS
the environment variable for the sshpass binary (Linux/Mac).- See Also:
- Constant Field Values
-
RSYNC4J_SSHKEYGEN
public static final java.lang.String RSYNC4J_SSHKEYGEN
the environment variable for the ssh-keygen binary (Linux/Mac).- See Also:
- Constant Field Values
-
LIBRARIES
public static final java.lang.String LIBRARIES
- See Also:
- Constant Field Values
-
binariesExtracted
protected static java.lang.Boolean binariesExtracted
for storing any previously extract binary.
-
rsyncBinary
protected static java.lang.String rsyncBinary
the rsync binary.
-
sshBinary
protected static java.lang.String sshBinary
the ssh binary.
-
sshkeygenBinary
protected static java.lang.String sshkeygenBinary
the ssh-keygen binary.
-
sshpassBinary
protected static java.lang.String sshpassBinary
the sshpass binary.
-
sshpassBinaryPresent
protected static boolean sshpassBinaryPresent
whether the sshpass binary is present.
-
LOGGER
protected static java.util.logging.Logger LOGGER
for logging.
-
-
Method Detail
-
getBitness
public static int getBitness()
Returns the "bitness", ie 32 or 64 bit of the underlying OS.- Returns:
- the number of bits
-
copyResourceTo
protected static java.lang.String copyResourceTo(java.lang.String inDir, java.lang.String name, java.lang.String outDir) throws java.lang.ExceptionCopies the specified resource to the output directory.- Parameters:
inDir- the resource directory to usename- the name of the resourceoutDir- the output directory- Returns:
- the full path
- Throws:
java.lang.Exception
-
homeDir
protected static java.lang.String homeDir()
Returns the home directory to use for rsync4j. On Windows, use theWINDOWS_HOME_DIRenvironment variable to point it to a custom location.- Returns:
- the directory
-
getWindowsDir
protected static java.lang.String getWindowsDir()
Returns the sub-directory for the Windows binaries, depending on the bitness.- Returns:
- the sub-directory of the binaries
-
getLibraries
protected static java.util.List<java.lang.String> getLibraries() throws java.lang.ExceptionReturns the list of libraries to copy.- Returns:
- the libraries
- Throws:
java.lang.Exception- if reading
-
extractBinaries
protected static void extractBinaries() throws java.lang.ExceptionExtracts the binaries to the tmp directory.- Throws:
java.lang.Exception- if extraction fails
-
rsyncBinary
public static java.lang.String rsyncBinary() throws java.lang.ExceptionReturns the rsync binary (if necessary extracts the binaries to the temp directory).- Returns:
- the filename of the binary
- Throws:
java.lang.Exception- if extraction fails
-
sshBinary
public static java.lang.String sshBinary() throws java.lang.ExceptionReturns the ssh binary (if necessary extracts the binaries to the temp directory).- Returns:
- the filename of the binary
- Throws:
java.lang.Exception- if extraction fails
-
sshkeygenBinary
public static java.lang.String sshkeygenBinary() throws java.lang.ExceptionReturns the ssh-keygen binary (if necessary extracts the binaries to the temp directory).- Returns:
- the filename of the binary
- Throws:
java.lang.Exception- if extraction fails
-
sshpassBinaryPresent
public static boolean sshpassBinaryPresent() throws java.lang.ExceptionReturns whether the sshpass binary is present (if necessary extracts the binaries to the temp directory).- Returns:
- true if present
- Throws:
java.lang.Exception- if extraction fails
-
sshpassBinary
public static java.lang.String sshpassBinary() throws java.lang.ExceptionReturns the sshpass binary (if necessary extracts the binaries to the temp directory).- Returns:
- the filename of the binary
- Throws:
java.lang.Exception- if extraction fails
-
quotePath
public static java.lang.String quotePath(java.lang.String path)
Quotes the path if a single quote is in the name.- Parameters:
path- the path to quote- Returns:
- the (potentially) double quoted path
-
quotePath
public static java.lang.String quotePath(java.lang.String path, boolean force)Quotes the path if a single quote is in the name.- Parameters:
path- the path to quoteforce- forces double quoting- Returns:
- the (potentially) double quoted path
-
convertPath
public static java.lang.String convertPath(java.lang.String path)
Converts the path into cygwin notation on Windows platform.- Parameters:
path- the path to convert- Returns:
- the (potentially) converted path
-
-