Logo Search packages:      
Sourcecode: jftp version File versions  Download package

String [] net::sf::jftp::net::FtpConnection::sortSize (  )  [inline]

Sort the filesizes an return an array.

The Array should be in sync with the other sort*-Methods

Returns:
An String-array of sizes containing the size or -1 if failed or 0 for directories

Implements net::sf::jftp::net::BasicConnection.

Definition at line 375 of file FtpConnection.java.

References getOsType(), and giveSize().

Referenced by rawUpload().

    {
        try
        {
            currentSizes.removeAllElements();
            
            for(int i=0; i<currentListing.size(); i++)
            {
                String tmp = (String) currentListing.get(i);

                // ------------- VMS override -------------------
                if(getOsType().indexOf("VMS") >= 0)
                {
                    if(tmp.indexOf(";") < 0)
                    {
                        continue;
                    }

                    currentSizes.add("-1");

                    continue;
                }

                // ------------- MVS override -------------------
                if(getOsType().indexOf("MVS") >= 0)
                {
                    if(tmp.startsWith("Volume") || (tmp.indexOf(" ") < 0))
                    {
                         continue;
                    }

                    currentSizes.add("-1");

                    continue;
                }

                // ------------------------------------------------
                else if(getOsType().indexOf("WINDOW") >= 0)
                {
                    StringTokenizer to = new StringTokenizer(tmp, " ", false);

                    if(to.countTokens() >= 4)
                    {
                        to.nextToken();
                        to.nextToken();

                        String size = to.nextToken();

                        if(size.equals("<DIR>"))
                        {
                            currentSizes.add("0");
                        }
                        else
                        {
                            try
                            {
                                Long.parseLong(size);
                                currentSizes.add(size);
                            }
                            catch(Exception ex)
                            {
                              currentSizes.add("-1");
                                Log.out("WARNING: filesize can not be determined - value is " +
                                        size);
                            }
                        }
                    }
                }

                // ------------------------------------------------
                else if(getOsType().indexOf("OS/2") >= 0)
                {
                    StringTokenizer to = new StringTokenizer(tmp, " ", false);
                    tmp = giveSize(to, 0);
                    Log.out("OS/2 parser (size): " + tmp);
                    currentSizes.add(tmp);
                }
                else
                {
                    //Log.out("\n\nparser\n\n");
                    StringTokenizer to = new StringTokenizer(tmp, " ", false);

                    if(to.countTokens() >= 8) // unix
                    {
                        tmp = giveSize(to, 4);
                        currentSizes.add(tmp);

                        //Log.out(tmp);
                    }
                    else if(to.countTokens() == 7) // unix, too
                    {
                        Log.out("WARNING: 7 token backup size parser activated!");
                        tmp = giveSize(to, 4);
                        currentSizes.add(tmp);
                    }
                    else
                    {
                        Log.debug("cannot parse line: " + tmp);
                    }
                }
            }
        }
        catch(Exception ex)
        {
            Log.debug(ex.toString() + " @FtpConnection::sortSize#1");
            return new String[0];
        }

        return toArray(currentSizes);
    }


Generated by  Doxygen 1.6.0   Back to index