From 680d4a42a496929ddb2de74229b27d31c313f6c3 Mon Sep 17 00:00:00 2001 From: mdonohue Date: Thu, 8 May 2008 04:48:09 +0000 Subject: [PATCH] Add a renameTo method to the FilePath class git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9078 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index d5028c4b34..9a70ecb163 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -701,6 +701,22 @@ public final class FilePath implements Serializable { }); } + /** + * Rename this file/directory to the target filepath. This FilePath and the target must + * be on the some host + */ + public void renameTo(final FilePath target) throws IOException, InterruptedException { + if(this.channel != target.channel) { + throw new IOException("renameTo target must be on the same host"); + } + act(new FileCallable() { + public Void invoke(File f, VirtualChannel channel) throws IOException { + f.renameTo(new File(target.remote)); + return null; + } + }); + } + /** * Copies this file to the specified target. */