[Swift-commit] r3132 - trunk/src/org/griphyn/vdl/karajan/lib

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Sat Oct 10 20:48:37 CDT 2009


Author: hategan
Date: 2009-10-10 20:48:37 -0500 (Sat, 10 Oct 2009)
New Revision: 3132

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/PathUtils.java
Log:
use backslash if remote site is windows

Modified: trunk/src/org/griphyn/vdl/karajan/lib/PathUtils.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/PathUtils.java	2009-10-11 01:47:35 UTC (rev 3131)
+++ trunk/src/org/griphyn/vdl/karajan/lib/PathUtils.java	2009-10-11 01:48:37 UTC (rev 3132)
@@ -9,6 +9,7 @@
 import org.globus.cog.karajan.util.TypeUtil;
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.globus.cog.karajan.workflow.nodes.functions.FunctionsCollection;
+import org.griphyn.common.classes.Os;
 import org.griphyn.vdl.mapping.AbsFile;
 
 public class PathUtils extends FunctionsCollection {
@@ -67,25 +68,41 @@
     }
     
     public static final Arg DIR = new Arg.Positional("dir");
+    public static final Arg OS = new Arg.Optional("os");
+    
     static {
-        setArguments("vdl_dircat", new Arg[] { DIR, PATH });
+        setArguments("vdl_dircat", new Arg[] { DIR, PATH, OS });
     }
 
     public String vdl_dircat(VariableStack stack) throws ExecutionException {
         String dir = TypeUtil.toString(DIR.getValue(stack));
     	String path = TypeUtil.toString(PATH.getValue(stack));
+    	boolean windows = false;
+    	if (OS.isPresent(stack)) {
+    		Os os = (Os) OS.getValue(stack);
+    		windows = Os.WINDOWS.equals(os);
+    	}
         if (dir.equals("")) {
-            return path;
+            return windowsify(path, windows);
         }
         else if (dir.endsWith("/")) {
-            return dir + path;
+        	return windowsify(dir + path, windows);
         }
         else {
-            return dir + '/' + path;
+            return windowsify(dir + '/' + path, windows);
         }
     }
     
-    public static final Arg FILES = new Arg.Positional("files");
+    private String windowsify(String path, boolean windows) {
+		if (windows) {
+			return path.replace('/', '\\');
+		}
+		else {
+			return path;
+		}
+	}
+
+	public static final Arg FILES = new Arg.Positional("files");
     static {
         setArguments("vdl_pathnames", new Arg[] { FILES });
     }




More information about the Swift-commit mailing list