From 6f4edfcbf5c5fc74c9ee2d1cc266f9ed1f54586d Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 4 Nov 2009 19:29:25 +0000 Subject: [PATCH] this is more portable. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23471 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Util.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 2e740d4d13..46a5936362 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -29,8 +29,8 @@ import static hudson.model.Hudson.isWindows; import hudson.util.IOException2; import hudson.util.QuotedStringTokenizer; import hudson.util.VariableResolver; +import hudson.util.jna.GNUCLibrary; import hudson.Proc.LocalProc; -import hudson.os.PosixAPI; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; @@ -88,6 +88,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.nio.charset.Charset; +import com.sun.jna.Native; + /** * Various utility methods that don't have more proper home. * @@ -964,16 +966,16 @@ public class Util { new LocalProc(new String[]{"rm","-rf", symlinkPath},new String[0],listener.getLogger(), baseDir).join(); int r; - String errMsg = ""; - if (!SYMLINK_ESCAPEHATCH && PosixAPI.isNative()) { - r = PosixAPI.get().symlink(targetPath,symlinkFile.getAbsolutePath()); - if (r!=0) errMsg = " errno=" + PosixAPI.get().errno(); - } else // escape hatch, until we know that the above works well. + if (!SYMLINK_ESCAPEHATCH) { + r = GNUCLibrary.LIBC.symlink(targetPath,symlinkFile.getAbsolutePath()); + if (r!=0) + r = Native.getLastError(); + } else // escape hatch, until we know that the above works well. r = new LocalProc(new String[]{ "ln","-s", targetPath, symlinkPath}, new String[0],listener.getLogger(), baseDir).join(); if(r!=0) - listener.getLogger().println("ln failed: "+r+errMsg); + listener.getLogger().println("ln failed: "+r); } catch (IOException e) { PrintStream log = listener.getLogger(); log.println("ln failed");