Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 75311 invoked from network); 29 Jan 2005 15:29:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Jan 2005 15:29:12 -0000 Received: (qmail 57943 invoked by uid 500); 29 Jan 2005 15:29:09 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 57844 invoked by uid 500); 29 Jan 2005 15:29:09 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 57831 invoked by uid 500); 29 Jan 2005 15:29:09 -0000 Received: (qmail 57828 invoked by uid 99); 29 Jan 2005 15:29:08 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 29 Jan 2005 07:29:08 -0800 Received: (qmail 75215 invoked by uid 65534); 29 Jan 2005 15:29:07 -0000 Date: 29 Jan 2005 15:29:07 -0000 Message-ID: <20050129152907.75212.qmail@minotaur.apache.org> From: imario@apache.org To: commons-cvs@jakarta.apache.org Subject: svn commit: r149047 - /jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java /jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: imario Date: Sat Jan 29 07:29:06 2005 New Revision: 149047 URL: http://svn.apache.org/viewcvs?view=rev&rev=149047 Log: PR: 32356 Submitted by: Anthony Goubard srcdirisbase optional Ant copy task attribute Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java?view=diff&rev=149047&p1=jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java&r1=149046&p2=jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java&r2=149047 ============================================================================== --- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java (original) +++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/tasks/AbstractSyncTask.java Sat Jan 29 07:29:06 2005 @@ -40,7 +40,7 @@ *
  • Up-to-date destination file. * * @author Adam Murdoch - * @version $Revision: 1.13 $ $Date: 2004/12/03 20:33:51 $ + * @version $Revision: 1.13 $ $Date$ * @todo Deal with case where dest file maps to a child of one of the source files * @todo Deal with case where dest file already exists and is incorrect type (not file, not a folder) * @todo Use visitors @@ -56,6 +56,7 @@ private String destFileUrl; private String destDirUrl; private String srcDirUrl; + private boolean srcDirIsBase; private String filesList; /** @@ -93,6 +94,14 @@ } /** + * Sets whether the source directory should be consider as the base directory. + */ + public void setSrcDirIsBase(final boolean srcDirIsBase) + { + this.srcDirIsBase = srcDirIsBase; + } + + /** * Sets the files to includes */ public void setIncludes(final String filesList) @@ -197,6 +206,11 @@ destFolder.createFolder(); // Locate the source files, and make sure they exist + FileName srcDirName = null; + if (srcDirUrl !=null ) + { + srcDirName = resolveFile(srcDirUrl).getName(); + } final ArrayList srcs = new ArrayList(); for (int i = 0; i < srcFiles.size(); i++) { @@ -225,7 +239,16 @@ if (rootFile.getType() == FileType.FILE) { // Build the destination file name - final FileObject destFile = destFolder.resolveFile(rootName.getBaseName(), NameScope.DESCENDENT); + String relName = null; + if (srcDirName == null || !srcDirIsBase) + { + relName = rootName.getBaseName(); + } + else + { + relName = srcDirName.getRelativeName(rootName); + } + final FileObject destFile = destFolder.resolveFile(relName, NameScope.DESCENDENT); // Do the copy handleFile(destFiles, rootFile, destFile); @@ -233,13 +256,23 @@ else { // Find matching files - final FileObject[] files = rootFile.findFiles(Selectors.SELECT_FILES); + // If srcDirIsBase is true, select also the sub-directories + final FileObject[] files = rootFile.findFiles(srcDirIsBase ? Selectors.SELECT_ALL : Selectors.SELECT_FILES); + for (int j = 0; j < files.length; j++) { final FileObject srcFile = files[j]; // Build the destination file name - String relName = rootName.getRelativeName(srcFile.getName()); + String relName = null; + if (srcDirName == null || !srcDirIsBase) + { + relName = rootName.getRelativeName(srcFile.getName()); + } + else + { + relName = srcDirName.getRelativeName(srcFile.getName()); + } final FileObject destFile = destFolder.resolveFile(relName, NameScope.DESCENDENT); Modified: jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml?view=diff&rev=149047&p1=jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml&r1=149046&p2=jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml&r2=149047 ============================================================================== --- jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml (original) +++ jakarta/commons/sandbox/vfs/trunk/xdocs/anttasks.xml Sat Jan 29 07:29:06 2005 @@ -132,6 +132,14 @@ + srcdirisbase + Set whether the source directory should be used as base directory. + If set to true, the subdirectories of the specified directories will be copied as well. + No, default is + false. + + + src A source file or folder to copy. Copies all descendents of a folder. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org