mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 14:02:22 +00:00
this is more portable.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23471 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
c825c2bbfd
commit
6f4edfcbf5
1 file changed
+9
-7
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user