ASF Bugzilla – Attachment 21763 Details for
Bug 44726
selectors on remote FTP directories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
same, but 1.3 compliant.
issues.apache.org-044726.diff (text/plain), 6.93 KB, created by
Mario Frasca
on 2008-04-02 02:32:00 UTC
(
hide
)
Description:
same, but 1.3 compliant.
Filename:
MIME Type:
Creator:
Mario Frasca
Created:
2008-04-02 02:32:00 UTC
Size:
6.93 KB
patch
obsolete
>Index: main/org/apache/tools/ant/taskdefs/optional/net/FTP.java >=================================================================== >--- main/org/apache/tools/ant/taskdefs/optional/net/FTP.java (revision 643306) >+++ main/org/apache/tools/ant/taskdefs/optional/net/FTP.java (working copy) >@@ -32,12 +32,10 @@ > import java.util.Date; > import java.util.Enumeration; > import java.util.HashMap; >-import java.util.HashSet; > import java.util.Hashtable; > import java.util.Iterator; > import java.util.Locale; > import java.util.Map; >-import java.util.Set; > import java.util.StringTokenizer; > import java.util.Vector; > >@@ -170,8 +168,147 @@ > "site command" > }; > >+ /** >+ * internal class providing a File-like interface to some of the information >+ * available from the FTP server >+ * >+ */ >+ protected class FTPFileProxy extends File { > >- /** >+ private FTPFile m_file; >+ private String[] m_parts; >+ private String m_name; >+ >+ /** >+ * creates a proxy to a FTP file >+ * @param file >+ */ >+ public FTPFileProxy(FTPFile file) { >+ super(file.getName()); >+ m_name = file.getName(); >+ m_file = file; >+ m_parts = FileUtils.getPathStack(m_file.getName()); >+ } >+ >+ /** >+ * creates a proxy to a FTP directory >+ * @param completePath the remote directory. >+ */ >+ public FTPFileProxy(String completePath) { >+ super(completePath); >+ m_file = null; >+ m_name = completePath; >+ m_parts = FileUtils.getPathStack(completePath); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#exists() >+ */ >+ public boolean exists() { >+ return true; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#getAbsolutePath() >+ */ >+ public String getAbsolutePath() { >+ return m_name; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#getName() >+ */ >+ public String getName() { >+ return m_parts[m_parts.length-1]; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#getParent() >+ */ >+ public String getParent() { >+ String result = ""; >+ for(int i=0; i<m_parts.length-1; i++){ >+ result += File.separatorChar + m_parts[i]; >+ } >+ return result; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#getPath() >+ */ >+ public String getPath() { >+ return m_name; >+ } >+ >+ >+ /** >+ * FTP files are stored as absolute paths >+ * @return true >+ */ >+ public boolean isAbsolute() { >+ return true; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#isDirectory() >+ */ >+ public boolean isDirectory() { >+ return m_file == null; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#isFile() >+ */ >+ public boolean isFile() { >+ return m_file != null; >+ } >+ >+ >+ /** >+ * FTP files cannot be hidden >+ * >+ * @return false >+ */ >+ public boolean isHidden() { >+ return false; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#lastModified() >+ */ >+ public long lastModified() { >+ if (m_file != null) >+ return m_file.getTimestamp().getTimeInMillis(); >+ return 0; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see java.io.File#length() >+ */ >+ public long length() { >+ if(m_file != null) >+ return m_file.getSize(); >+ return 0; >+ } >+ >+ >+ /** >+ * >+ */ >+ private static final long serialVersionUID = 1L; >+ >+ } >+ >+ /** > * internal class allowing to read the contents of a remote file system > * using the FTP protocol > * used in particular for ftp get operations >@@ -206,7 +343,7 @@ > > /** > * scans the remote directory, >- * storing internally the included files, directories, ... >+ * storing internally the included files, directories, ... > */ > public void scan() { > if (includes == null) { >@@ -341,7 +478,8 @@ > } > } > /** >- * scans a particular directory >+ * scans a particular directory. populates the scannedDirs cache. >+ * > * @param dir directory to scan > * @param vpath relative path to the base directory of the remote fileset > * always ended with a File.separator >@@ -374,8 +512,9 @@ > if (file != null > && !file.getName().equals(".") > && !file.getName().equals("..")) { >+ String name = vpath + file.getName(); >+ scannedDirs.put(name, new FTPFileProxy(file)); > if (isFunctioningAsDirectory(ftp, dir, file)) { >- String name = vpath + file.getName(); > boolean slowScanAllowed = true; > if (!isFollowSymlinks() && file.isSymbolicLink()) { > dirsExcluded.addElement(name); >@@ -395,7 +534,6 @@ > name + File.separator, fast); > } > } else { >- String name = vpath + file.getName(); > if (!isFollowSymlinks() && file.isSymbolicLink()) { > filesExcluded.addElement(name); > } else if (isFunctioningAsFile(ftp, dir, file)) { >@@ -419,7 +557,7 @@ > && !filesExcluded.contains(name)) { > > if (isIncluded(name)) { >- if (!isExcluded(name)) { >+ if (!isExcluded(name) && isSelected(name, (File)scannedDirs.get(name))) { > filesIncluded.addElement(name); > } else { > filesExcluded.addElement(name); >@@ -487,18 +625,17 @@ > * > * @since Ant 1.6 > */ >- private Set scannedDirs = new HashSet(); > >+ private Map scannedDirs = new HashMap(); >+ > /** > * Has the directory with the given path relative to the base > * directory already been scanned? > * >- * <p>Registers the given directory as scanned as a side effect.</p> >- * > * @since Ant 1.6 > */ > private boolean hasBeenScanned(String vpath) { >- return !scannedDirs.add(vpath); >+ return scannedDirs.containsKey(vpath); > } > > /** >@@ -1566,11 +1703,6 @@ > if (action == SEND_FILES) { > ds = fs.getDirectoryScanner(getProject()); > } else { >- // warn that selectors are not supported >- if (fs.getSelectors(getProject()).length != 0) { >- getProject().log("selectors are not supported in remote filesets", >- Project.MSG_WARN); >- } > ds = new FTPDirectoryScanner(ftp); > fs.setupDirectoryScanner(ds, getProject()); > ds.setFollowSymlinks(fs.isFollowSymlinks()); >@@ -1738,7 +1870,6 @@ > return; > } > >- > Vector parents = new Vector(); > String dirname; >
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 44726
:
21761
|
21762
| 21763