Class SMB


  • public class SMB
    extends Object
    Class for SMB actions.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • SMB

        public SMB()
    • 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 null
        provider - the SMB authentication provider to use
        localFile - the local file
        share - the share to copy to
        remoteFile - 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 null
        provider - the SMB authentication provider to use
        localFile - the local file
        share - the share to copy to
        remoteFile - 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 transfer
        provider - the SMB session provider to use
        share - the share to copy from
        remoteFile - the remote file to copy
        localFile - 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 transfer
        provider - the SMB session provider to use
        share - the share to copy from
        remoteFile - the remote file to copy
        localFile - 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 join
        isDir - 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
      • fixSubDir

        public static String fixSubDir​(String path)
        Ensures that the path ends with /.
        Parameters:
        path - the path to process
        Returns:
        the (potentially) fixed path