Lines 31-36
Link Here
|
31 |
import java.util.Vector; |
31 |
import java.util.Vector; |
32 |
import java.util.Iterator; |
32 |
import java.util.Iterator; |
33 |
|
33 |
|
|
|
34 |
// for NIO support: |
35 |
import java.io.FileInputStream; |
36 |
import java.io.FileOutputStream; |
37 |
import java.nio.channels.FileChannel; |
38 |
import org.apache.tools.ant.types.resources.FileResource; |
39 |
|
34 |
import org.apache.tools.ant.Project; |
40 |
import org.apache.tools.ant.Project; |
35 |
import org.apache.tools.ant.ProjectComponent; |
41 |
import org.apache.tools.ant.ProjectComponent; |
36 |
import org.apache.tools.ant.filters.util.ChainReaderHelper; |
42 |
import org.apache.tools.ant.filters.util.ChainReaderHelper; |
Lines 77-82
Link Here
|
77 |
|
83 |
|
78 |
private static final ResourceSelector NOT_EXISTS = new Not(new Exists()); |
84 |
private static final ResourceSelector NOT_EXISTS = new Not(new Exists()); |
79 |
|
85 |
|
|
|
86 |
// for NIO support: |
87 |
private static final int TRANSFER_SIZE = 65535; |
88 |
|
80 |
/** |
89 |
/** |
81 |
* Tells which source files should be reprocessed based on the |
90 |
* Tells which source files should be reprocessed based on the |
82 |
* last modification date of target files. |
91 |
* last modification date of target files. |
Lines 372-377
Link Here
|
372 |
FileUtils.close(in); |
381 |
FileUtils.close(in); |
373 |
} |
382 |
} |
374 |
} else { |
383 |
} else { |
|
|
384 |
if( source instanceof FileResource && dest instanceof FileResource ) { |
385 |
File sourceFile = ((FileResource) source).getFile(); |
386 |
File destFile = ((FileResource) dest).getFile(); |
387 |
|
388 |
FileInputStream in = null; |
389 |
FileOutputStream out = null; |
390 |
FileChannel srcChannel = null; |
391 |
FileChannel destChannel = null; |
392 |
|
393 |
try { |
394 |
File parent = destFile.getParentFile(); |
395 |
if (parent != null && !parent.exists()) { |
396 |
parent.mkdirs(); |
397 |
} |
398 |
|
399 |
in = new FileInputStream(sourceFile); |
400 |
out = new FileOutputStream(destFile); |
401 |
|
402 |
srcChannel = in.getChannel(); |
403 |
destChannel = out.getChannel(); |
404 |
|
405 |
long position = 0; |
406 |
long count = srcChannel.size(); |
407 |
while( position < count ) { |
408 |
position += srcChannel.transferTo(position, TRANSFER_SIZE, destChannel); |
409 |
} |
410 |
} finally { |
411 |
if (srcChannel != null) srcChannel.close(); |
412 |
if (destChannel != null) destChannel.close(); |
413 |
FileUtils.close(out); |
414 |
FileUtils.close(in); |
415 |
} |
416 |
} else { |
417 |
System.out.println("Not ennabling NIO file copies. Boo!"); |
375 |
InputStream in = null; |
418 |
InputStream in = null; |
376 |
OutputStream out = null; |
419 |
OutputStream out = null; |
377 |
try { |
420 |
try { |
Lines 389-394
Link Here
|
389 |
FileUtils.close(in); |
432 |
FileUtils.close(in); |
390 |
} |
433 |
} |
391 |
} |
434 |
} |
|
|
435 |
} |
392 |
if (preserveLastModified && dest instanceof Touchable) { |
436 |
if (preserveLastModified && dest instanceof Touchable) { |
393 |
setLastModified((Touchable) dest, source.getLastModified()); |
437 |
setLastModified((Touchable) dest, source.getLastModified()); |
394 |
} |
438 |
} |