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
This commit is contained in:
mdonohue committed 2008-05-08 04:48:09 +00:00
1 parent 82780ed40e
commit 680d4a42a4
1 file changed
+16
+16
View File
@@ -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<Void>() {
public Void invoke(File f, VirtualChannel channel) throws IOException {
f.renameTo(new File(target.remote));
return null;
}
});
}
/**
* Copies this file to the specified target.
*/