use of org.apache.tools.ant.taskdefs.Delete in project ant by apache.
the class FTPTaskMirrorImpl method getTimeDiff.
/**
* auto find the time difference between local and remote
* @param ftp handle to ftp client
* @return number of millis to add to remote time to make it comparable to local time
* @since ant 1.6
*/
private long getTimeDiff(FTPClient ftp) {
long returnValue = 0;
File tempFile = findFileName(ftp);
try {
// create a local temporary file
FILE_UTILS.createNewFile(tempFile);
long localTimeStamp = tempFile.lastModified();
BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
ftp.storeFile(tempFile.getName(), instream);
instream.close();
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
FTPFile[] ftpFiles = ftp.listFiles(tempFile.getName());
if (ftpFiles.length == 1) {
long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
returnValue = localTimeStamp - remoteTimeStamp;
}
ftp.deleteFile(ftpFiles[0].getName());
}
// delegate the deletion of the local temp file to the delete task
// because of race conditions occurring on Windows
Delete mydelete = new Delete();
mydelete.bindToOwner(task);
mydelete.setFile(tempFile.getCanonicalFile());
mydelete.execute();
} catch (Exception e) {
throw new BuildException(e, task.getLocation());
}
return returnValue;
}
use of org.apache.tools.ant.taskdefs.Delete in project ant-ivy by apache.
the class IvyDeliverTest method cleanTestDir.
private void cleanTestDir() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("build/test/deliver"));
del.execute();
}
use of org.apache.tools.ant.taskdefs.Delete in project ant-ivy by apache.
the class IvyDeliverTest method cleanRep.
private void cleanRep() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("test/repositories/1/apache"));
del.execute();
}
use of org.apache.tools.ant.taskdefs.Delete in project ant-ivy by apache.
the class TestPerformance method cleanRepo.
private void cleanRepo() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("build/test/perf"));
del.execute();
}
use of org.apache.tools.ant.taskdefs.Delete in project ant-ivy by apache.
the class DefaultRepositoryCacheManagerTest method tearDown.
@After
public void tearDown() {
IvyContext.popContext();
Delete del = new Delete();
del.setProject(new Project());
del.setDir(cacheManager.getRepositoryCacheRoot());
del.execute();
}
Aggregations