View | Details | Raw Unified | Return to bug 12765
Collapse All | Expand All

(-)FTP.java.orig (-10 / +64 lines)
Lines 87-92 Link Here
87
 *   <li> <strong>del</strong> - delete files from a remote server.</li>
87
 *   <li> <strong>del</strong> - delete files from a remote server.</li>
88
 *   <li> <strong>list</strong> - create a file listing.</li>
88
 *   <li> <strong>list</strong> - create a file listing.</li>
89
 *   <li> <strong>chmod</strong> - change unix file permissions.</li>
89
 *   <li> <strong>chmod</strong> - change unix file permissions.</li>
90
 *   <li> <strong>rmdir</strong> - remove directories, if empty, from a 
91
 *   remote server.</li>
90
 * </ul>
92
 * </ul>
91
 * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem
93
 * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem
92
 * to hold data ports open after a "retr" operation, allowing them to timeout
94
 * to hold data ports open after a "retr" operation, allowing them to timeout
Lines 110-115 Link Here
110
    protected static final int LIST_FILES = 3;
112
    protected static final int LIST_FILES = 3;
111
    protected static final int MK_DIR = 4;
113
    protected static final int MK_DIR = 4;
112
    protected static final int CHMOD = 5;
114
    protected static final int CHMOD = 5;
115
    protected static final int RM_DIR = 6;
113
116
114
    private String remotedir;
117
    private String remotedir;
115
    private String server;
118
    private String server;
Lines 139-145 Link Here
139
        "deleting",
142
        "deleting",
140
        "listing",
143
        "listing",
141
        "making directory",
144
        "making directory",
142
        "chmod"
145
        "chmod",
146
        "removing"
143
        };
147
        };
144
148
145
    protected static final String[] COMPLETED_ACTION_STRS = {
149
    protected static final String[] COMPLETED_ACTION_STRS = {
Lines 148-154 Link Here
148
        "deleted",
152
        "deleted",
149
        "listed",
153
        "listed",
150
        "created directory",
154
        "created directory",
151
        "mode changed"
155
        "mode changed",
156
        "removed"
157
        };
158
159
    protected static final String[] ACTION_TARGET_STRS = {
160
        "files",
161
        "files",
162
        "files",
163
        "files",
164
        "directory",
165
        "files",
166
        "directories"
152
        };
167
        };
153
168
154
169
Lines 212-222 Link Here
212
                            String name = vpath + file.getName();
227
                            String name = vpath + file.getName();
213
                            if (isIncluded(name)) {
228
                            if (isIncluded(name)) {
214
                                if (!isExcluded(name)) {
229
                                if (!isExcluded(name)) {
215
                                    dirsIncluded.addElement(name);
216
                                    if (fast) {
230
                                    if (fast) {
217
                                        scandir(file.getName(), 
231
                                        scandir(file.getName(), 
218
                                                name + File.separator, fast);
232
                                                name + File.separator, fast);
219
                                    }
233
                                    }
234
                                    dirsIncluded.addElement(name);
220
                                } else {
235
                                } else {
221
                                    dirsExcluded.addElement(name);
236
                                    dirsExcluded.addElement(name);
222
                                    if (fast && couldHoldIncluded(name)) {
237
                                    if (fast && couldHoldIncluded(name)) {
Lines 478-484 Link Here
478
            ds.scan();
493
            ds.scan();
479
        }
494
        }
480
495
481
        String[] dsfiles = ds.getIncludedFiles();
496
        String[] dsfiles = null;
497
        if (action == RM_DIR) {
498
            dsfiles = ds.getIncludedDirectories();
499
        } else {
500
            dsfiles = ds.getIncludedFiles();
501
        }
482
        String dir = null;
502
        String dir = null;
483
503
484
        if ((ds.getBasedir() == null)
504
        if ((ds.getBasedir() == null)
Lines 537-542 Link Here
537
                        break;
557
                        break;
538
                    }
558
                    }
539
559
560
                    case RM_DIR:
561
                    {
562
                        rmDir(ftp, dsfiles[i]);
563
                        break;
564
                    }
565
540
                    default:
566
                    default:
541
                    {
567
                    {
542
                        throw new BuildException("unknown ftp action " + action);
568
                        throw new BuildException("unknown ftp action " + action);
Lines 575-584 Link Here
575
            }
601
            }
576
        }
602
        }
577
603
578
        log(transferred + " files " + COMPLETED_ACTION_STRS[action]);
604
        log(transferred + " " + ACTION_TARGET_STRS[action] + " " +
605
				COMPLETED_ACTION_STRS[action]);
579
        if (skipped != 0) {
606
        if (skipped != 0) {
580
            log(skipped + " files were not successfully "
607
            log(skipped + " " + ACTION_TARGET_STRS[action] + 
581
                 + COMPLETED_ACTION_STRS[action]);
608
				" were not successfully "
609
                + COMPLETED_ACTION_STRS[action]);
582
        }
610
        }
583
    }
611
    }
584
612
Lines 775-780 Link Here
775
        }
803
        }
776
    }
804
    }
777
805
806
    /** Delete a directory, if empty, from the remote host.  */
807
    protected void rmDir(FTPClient ftp, String dirname)
808
         throws IOException, BuildException {
809
        if (verbose) {
810
            log("removing " + dirname);
811
        }
812
813
        if (!ftp.removeDirectory(resolveFile(dirname))) {
814
            String s = "could not remove directory: " + ftp.getReplyString();
815
816
            if (skipFailedTransfers == true) {
817
                log(s, Project.MSG_WARN);
818
                skipped++;
819
            } else {
820
                throw new BuildException(s);
821
            }
822
        } else {
823
            log("Directory " + dirname + " removed from " + server,
824
                Project.MSG_VERBOSE);
825
            transferred++;
826
        }
827
    }
828
778
829
779
    /**
830
    /**
780
     * Retrieve a single file to the remote host. <code>filename</code> may
831
     * Retrieve a single file to the remote host. <code>filename</code> may
Lines 973-979 Link Here
973
                            ftp.getReplyString());
1024
                            ftp.getReplyString());
974
                    }
1025
                    }
975
                }
1026
                }
976
                log(ACTION_STRS[action] + " files");
1027
                log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]);
977
                transferFiles(ftp);
1028
                transferFiles(ftp);
978
            }
1029
            }
979
1030
Lines 995-1007 Link Here
995
1046
996
    /**
1047
    /**
997
     * an action to perform, one of 
1048
     * an action to perform, one of 
998
     * "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod"
1049
     * "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod",
1050
     * "rmdir"
999
     */
1051
     */
1000
    public static class Action extends EnumeratedAttribute {
1052
    public static class Action extends EnumeratedAttribute {
1001
1053
1002
        private static final String[] validActions = {
1054
        private static final String[] validActions = {
1003
            "send", "put", "recv", "get", "del", "delete", "list", "mkdir",
1055
            "send", "put", "recv", "get", "del", "delete", "list", "mkdir",
1004
            "chmod"
1056
            "chmod", "rmdir"
1005
            };
1057
            };
1006
1058
1007
1059
Lines 1028-1033 Link Here
1028
                return CHMOD;
1080
                return CHMOD;
1029
            } else if (actionL.equals("mkdir")) {
1081
            } else if (actionL.equals("mkdir")) {
1030
                return MK_DIR;
1082
                return MK_DIR;
1083
            } else if (actionL.equals("rmdir")) {
1084
                return RM_DIR;
1031
            }
1085
            }
1032
            return SEND_FILES;
1086
            return SEND_FILES;
1033
        }
1087
        }

Return to bug 12765