From c462cb634c7a8585af159dec6417f4d8d14d2e3f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 18 Jul 2013 20:14:15 -0700 Subject: [PATCH] added a convenience method --- core/src/main/java/hudson/FilePath.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 2958c08bd6..2bb8065469 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -2450,4 +2450,16 @@ public final class FilePath implements Serializable { throw new AssertionError(e); } } + + /** + * Gets the {@link FilePath} representation of the "~" directory + * (User's home directory in the Unix sense) of the given channel. + */ + public static FilePath getHomeDirectory(VirtualChannel ch) throws InterruptedException, IOException { + ch.call(new Callable() { + public FilePath call() throws IOException { + return new FilePath(new File(System.getProperty("user.home"))); + } + }); + } }