ASF Bugzilla – Attachment 3112 Details for
Bug 12765
"rmdir" and "deltree" patches for ftp task enhancement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
"rmdir" action patch
FTP.java.rmdir.patch (text/plain), 5.34 KB, created by
Gabriele Garuglieri
on 2002-09-18 12:26:46 UTC
(
hide
)
Description:
"rmdir" action patch
Filename:
MIME Type:
Creator:
Gabriele Garuglieri
Created:
2002-09-18 12:26:46 UTC
Size:
5.34 KB
patch
obsolete
>--- FTP.java.orig Tue Sep 17 13:39:35 2002 >+++ FTP.java Tue Sep 17 14:40:21 2002 >@@ -87,6 +87,8 @@ > * <li> <strong>del</strong> - delete files from a remote server.</li> > * <li> <strong>list</strong> - create a file listing.</li> > * <li> <strong>chmod</strong> - change unix file permissions.</li> >+ * <li> <strong>rmdir</strong> - remove directories, if empty, from a >+ * remote server.</li> > * </ul> > * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem > * to hold data ports open after a "retr" operation, allowing them to timeout >@@ -110,6 +112,7 @@ > protected static final int LIST_FILES = 3; > protected static final int MK_DIR = 4; > protected static final int CHMOD = 5; >+ protected static final int RM_DIR = 6; > > private String remotedir; > private String server; >@@ -139,7 +142,8 @@ > "deleting", > "listing", > "making directory", >- "chmod" >+ "chmod", >+ "removing" > }; > > protected static final String[] COMPLETED_ACTION_STRS = { >@@ -148,7 +152,18 @@ > "deleted", > "listed", > "created directory", >- "mode changed" >+ "mode changed", >+ "removed" >+ }; >+ >+ protected static final String[] ACTION_TARGET_STRS = { >+ "files", >+ "files", >+ "files", >+ "files", >+ "directory", >+ "files", >+ "directories" > }; > > >@@ -212,11 +227,11 @@ > String name = vpath + file.getName(); > if (isIncluded(name)) { > if (!isExcluded(name)) { >- dirsIncluded.addElement(name); > if (fast) { > scandir(file.getName(), > name + File.separator, fast); > } >+ dirsIncluded.addElement(name); > } else { > dirsExcluded.addElement(name); > if (fast && couldHoldIncluded(name)) { >@@ -478,7 +493,12 @@ > ds.scan(); > } > >- String[] dsfiles = ds.getIncludedFiles(); >+ String[] dsfiles = null; >+ if (action == RM_DIR) { >+ dsfiles = ds.getIncludedDirectories(); >+ } else { >+ dsfiles = ds.getIncludedFiles(); >+ } > String dir = null; > > if ((ds.getBasedir() == null) >@@ -537,6 +557,12 @@ > break; > } > >+ case RM_DIR: >+ { >+ rmDir(ftp, dsfiles[i]); >+ break; >+ } >+ > default: > { > throw new BuildException("unknown ftp action " + action); >@@ -575,10 +601,12 @@ > } > } > >- log(transferred + " files " + COMPLETED_ACTION_STRS[action]); >+ log(transferred + " " + ACTION_TARGET_STRS[action] + " " + >+ COMPLETED_ACTION_STRS[action]); > if (skipped != 0) { >- log(skipped + " files were not successfully " >- + COMPLETED_ACTION_STRS[action]); >+ log(skipped + " " + ACTION_TARGET_STRS[action] + >+ " were not successfully " >+ + COMPLETED_ACTION_STRS[action]); > } > } > >@@ -775,6 +803,29 @@ > } > } > >+ /** Delete a directory, if empty, from the remote host. */ >+ protected void rmDir(FTPClient ftp, String dirname) >+ throws IOException, BuildException { >+ if (verbose) { >+ log("removing " + dirname); >+ } >+ >+ if (!ftp.removeDirectory(resolveFile(dirname))) { >+ String s = "could not remove directory: " + ftp.getReplyString(); >+ >+ if (skipFailedTransfers == true) { >+ log(s, Project.MSG_WARN); >+ skipped++; >+ } else { >+ throw new BuildException(s); >+ } >+ } else { >+ log("Directory " + dirname + " removed from " + server, >+ Project.MSG_VERBOSE); >+ transferred++; >+ } >+ } >+ > > /** > * Retrieve a single file to the remote host. <code>filename</code> may >@@ -973,7 +1024,7 @@ > ftp.getReplyString()); > } > } >- log(ACTION_STRS[action] + " files"); >+ log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]); > transferFiles(ftp); > } > >@@ -995,13 +1046,14 @@ > > /** > * an action to perform, one of >- * "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod" >+ * "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod", >+ * "rmdir" > */ > public static class Action extends EnumeratedAttribute { > > private static final String[] validActions = { > "send", "put", "recv", "get", "del", "delete", "list", "mkdir", >- "chmod" >+ "chmod", "rmdir" > }; > > >@@ -1028,6 +1080,8 @@ > return CHMOD; > } else if (actionL.equals("mkdir")) { > return MK_DIR; >+ } else if (actionL.equals("rmdir")) { >+ return RM_DIR; > } > return SEND_FILES; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 12765
: 3112 |
3113
|
3114
|
3115