Package adams.core.net
Class SMB
- java.lang.Object
-
- adams.core.net.SMB
-
public class SMB extends Object
Class for SMB actions.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description SMB()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
copyFrom(LoggingObject owner, SMBSessionProvider provider, com.hierynomus.smbj.share.DiskShare share, String remoteFile, File localFile)
Copies a remote file onto the local machine.static String
copyFrom(LoggingObject owner, SMBSessionProvider provider, String share, String remoteFile, File localFile)
Copies a remote file onto the local machine.static String
copyTo(LoggingObject owner, SMBSessionProvider provider, File localFile, com.hierynomus.smbj.share.DiskShare share, String remoteFile)
Copies a local file to a remote server.static String
copyTo(LoggingObject owner, SMBSessionProvider provider, File localFile, String share, String remoteFile)
Copies a local file to a remote server.static String
fixDir(String path)
Ensures that the path starts and ends with /.static String
fixSubDir(String path)
Ensures that the path ends with /.static String
getParent(String path)
Returns the parent path.static String[]
getParent(String[] elements)
Returns the parent path.static boolean
isDirectory(com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation file)
Checks whether the file object is a directory.static boolean
isHidden(com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation file)
Checks whether the file object is hidden.static String
joinPath(String[] elements, boolean isDir)
Creates a new path (with leading /).static String[]
splitPath(String path)
Splits the path into its individual elements.
-
-
-
Method Detail
-
copyTo
public static String copyTo(LoggingObject owner, SMBSessionProvider provider, File localFile, String share, String remoteFile)
Copies a local file to a remote server.- Parameters:
owner
- the owner that initiates the transfer, can be nullprovider
- the SMB authentication provider to uselocalFile
- the local fileshare
- the share to copy toremoteFile
- the remote file- Returns:
- null if successful, otherwise error message
-
copyTo
public static String copyTo(LoggingObject owner, SMBSessionProvider provider, File localFile, com.hierynomus.smbj.share.DiskShare share, String remoteFile)
Copies a local file to a remote server.- Parameters:
owner
- the owner that initiates the transfer, can be nullprovider
- the SMB authentication provider to uselocalFile
- the local fileshare
- the share to copy toremoteFile
- the remote file- Returns:
- null if successful, otherwise error message
-
copyFrom
public static String copyFrom(LoggingObject owner, SMBSessionProvider provider, String share, String remoteFile, File localFile)
Copies a remote file onto the local machine.- Parameters:
owner
- the owner that initiates the transferprovider
- the SMB session provider to useshare
- the share to copy fromremoteFile
- the remote file to copylocalFile
- the local file- Returns:
- null if successful, otherwise error message
-
copyFrom
public static String copyFrom(LoggingObject owner, SMBSessionProvider provider, com.hierynomus.smbj.share.DiskShare share, String remoteFile, File localFile)
Copies a remote file onto the local machine.- Parameters:
owner
- the owner that initiates the transferprovider
- the SMB session provider to useshare
- the share to copy fromremoteFile
- the remote file to copylocalFile
- the local file- Returns:
- null if successful, otherwise error message
-
isDirectory
public static boolean isDirectory(com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation file)
Checks whether the file object is a directory.- Parameters:
file
- the file object to check- Returns:
- true if directory
-
isHidden
public static boolean isHidden(com.hierynomus.msfscc.fileinformation.FileIdBothDirectoryInformation file)
Checks whether the file object is hidden.- Parameters:
file
- the file object to check- Returns:
- true if hidden
-
splitPath
public static String[] splitPath(String path)
Splits the path into its individual elements.- Parameters:
path
- the path to process- Returns:
- the path elements
-
joinPath
public static String joinPath(String[] elements, boolean isDir)
Creates a new path (with leading /).- Parameters:
elements
- the path elements to joinisDir
- whether the path represents a directory and requires a trailing /- Returns:
- the generated path
-
getParent
public static String getParent(String path)
Returns the parent path.- Parameters:
path
- the path to get the parent for- Returns:
- the parent path
-
getParent
public static String[] getParent(String[] elements)
Returns the parent path.- Parameters:
elements
- the path elements to get the parent for- Returns:
- the parent path elements
-
fixDir
public static String fixDir(String path)
Ensures that the path starts and ends with /.- Parameters:
path
- the path to process- Returns:
- the (potentially) fixed path
-
-