Class FSPutil

  • All Implemented Interfaces:

    
    public class FSPutil
    
                        

    Utilities for easier working with FSP.

    There are some higher level function for working with FSP.

    Since:

    1.0

    Author:

    Radim Kolar

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      FSPutil()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • FSPutil

        FSPutil()
    • Method Detail

      • download

         static void download(FSPsession session, String filename, OutputStream os, long start_from, long byteswanted)

        Downloads a file from FSP server.

        This procedure download a file from FSP server, file is written to OutputStream. OutputStream is not closed at end of transfer.

        Parameters:
        session - active FSP session
        filename - filename on FSP server
        os - write file to this stream
        start_from - offset where to start download
        byteswanted - how many bytes to download, <0 for all
        Since:

        1.0

      • upload

         static void upload(FSPsession session, String filename, InputStream is, long timestamp)

        Uploads file to FSP server

        Parameters:
        session - opened FSPsession to target server
        filename - filename on remote server
        is - InputStream to be sent to server.
        timestamp - timestamp for uploaded file, 0 if not used.
        Since:

        1.0rc7

      • stat

         static FSPstat stat(FSPsession session, String path)

        Gets information about file or directory.

        This function requests information about specific path from FSP server. Server must support CC_STAT command, which is supported from FSP 2.8.1 Beta 11.

        Parameters:
        session - FSPsession
        path - path for getting information
        Returns:

        FSPstat object or null if path is not found

        Since:

        1.0

      • statSupported

         static boolean statSupported(FSPsession session)

        Check if FSP server supports CC_STAT command. This command is implemented in fspd from FSP suite version 2.8.1 Beta 11 or later.

        This function is also suitable for detecting if FSP server is still alive. If you dont get IOException during function call then you are still connected to FSP server.

        Parameters:
        session - FSPsession
        Returns:

        true if CC_STAT command is supported

        Since:

        1.0

      • stringToASCIIZ

         static Array<byte> stringToASCIIZ(String filename)

        Converts String to ASCIIZ byte array.

        Parameters:
        filename - string to be converted
        Returns:

        converted byte array NULL terminated

        Since:

        1.0

      • list

         static Array<String> list(FSPsession session, String directory)

        get a filename directory list from server.

        Parameters:
        session - live FSPsession
        directory - directory to be listed
        Returns:

        file list

        Since:

        1.0

      • statlist

         static Array<FSPstat> statlist(FSPsession session, String directory)

        get a FSPstat directory list from server.

        Parameters:
        session - live FSPsession
        directory - directory to be listed
        Returns:

        FSPstat list or null on error

        Since:

        1.0

      • version

         static FSPversion version(FSPsession session)

        Sends CC_VERSION command to server and parses reply. Because some servers do not reply to CC_VERSION command, it should not be used for detection if FSPsession is still alive. Better is to use statSupported function instead.

        Parameters:
        session - live FSPsession
        Returns:

        FSPversion object

        Since:

        1.0rc7

      • canUpload

         static boolean canUpload(FSPsession session, String filename)

        Checks if user have enough rights to upload given file.

        Parameters:
        session - opened FSPsession
        filename - file to be uploaded
        Returns:

        true if user can upload file

        Since:

        1.0rc8