From 07bcb1a2f5b19d73de61235f7968da4020e6ad16 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 14 Jul 2007 19:47:15 +0000 Subject: [PATCH] Improved Windows/Unix detection (#631). git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3706 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 2 ++ core/src/main/java/hudson/model/Slave.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 6f897dad6e..719b01db93 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -158,6 +158,8 @@ public final class FilePath implements Serializable { * Checks if the remote path is Unix. */ private boolean isUnix() { + // Windows absolute path always include ':', but this is not a valid char in Unix file systems. + if(remote.contains(":")) return false; // Windows can handle '/' as a path separator but Unix can't, // so err on Unix side return remote.indexOf("\\")==-1; diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index 8169ba4720..a98ecc16c0 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -527,9 +527,10 @@ public final class Slave implements Node, Serializable { } public Launcher createLauncher(TaskListener listener) { + // Windows absolute path always include ':', but this is not a valid char in Unix file systems. // Windows can handle '/' as a path separator but Unix can't, // so err on Unix side - boolean isUnix = remoteFS.indexOf("\\") == -1; + boolean isUnix = !remoteFS.contains(":") && !remoteFS.contains("\\"); return new RemoteLauncher(listener, getComputer().getChannel(),isUnix); }