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

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Sat Jun 23 15:41:54 CDT 2012


Author: hategan
Date: 2012-06-23 15:41:54 -0500 (Sat, 23 Jun 2012)
New Revision: 5813

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/InFileDirs.java
   trunk/src/org/griphyn/vdl/karajan/lib/OutFileDirs.java
   trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
Log:
when using generic url for files, use the host name as a path prefix to avoid clashes between files with the same name on different hosts

Modified: trunk/src/org/griphyn/vdl/karajan/lib/InFileDirs.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/InFileDirs.java	2012-06-23 20:40:31 UTC (rev 5812)
+++ trunk/src/org/griphyn/vdl/karajan/lib/InFileDirs.java	2012-06-23 20:41:54 UTC (rev 5813)
@@ -44,17 +44,24 @@
         VariableArguments ret = ArgUtil.getVariableReturn(stack);
         for (Object f : files) { 
         	String path = (String) f;
-            String dir = new AbsFile(path).getDir();
-            // there could be a clash here since
-            // "/a/b/c.txt" would be remotely the same
-            // as "a/b/c.txt". Perhaps absolute paths
-            // should have a unique prefix.
-            if (dir.startsWith("/") && dir.length() != 1) {
-            	ret.append(dir.substring(1));
-            }
-            else if (dir.length() != 0) {
-                ret.append(dir);
-            }
+        	AbsFile af = new AbsFile(path);
+        	if ("file".equals(af.getProtocol())) {
+                String dir = af.getDir();
+                // there could be a clash here since
+                // "/a/b/c.txt" would be remotely the same
+                // as "a/b/c.txt". Perhaps absolute paths
+                // should have a unique prefix.
+                if (dir.startsWith("/") && dir.length() != 1) {
+                	ret.append(dir.substring(1));
+                }
+                else if (dir.length() != 0) {
+                    ret.append(dir);
+                }
+        	}
+        	else {
+        	    // also prepend host name to the path
+        	    ret.append(af.getHost() + "/" + af.getDir());
+        	}
         }
         super.post(stack);
     }

Modified: trunk/src/org/griphyn/vdl/karajan/lib/OutFileDirs.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/OutFileDirs.java	2012-06-23 20:40:31 UTC (rev 5812)
+++ trunk/src/org/griphyn/vdl/karajan/lib/OutFileDirs.java	2012-06-23 20:41:54 UTC (rev 5813)
@@ -50,12 +50,18 @@
                 DSHandle handle = (DSHandle) pv.get(1);
                 DSHandle leaf = handle.getField(p);
                 String fname = VDLFunction.filename(leaf)[0];
-                String dir = new AbsFile(fname).getDir();
-                if (dir.startsWith("/") && dir.length() != 1) {
-                    ret.append(dir.substring(1));
+                AbsFile af = new AbsFile(fname);
+                if ("file".equals(af.getProtocol())) {
+                    String dir = af.getDir();
+                    if (dir.startsWith("/") && dir.length() != 1) {
+                        ret.append(dir.substring(1));
+                    }
+                    else if (dir.length() != 0) {
+                        ret.append(dir);
+                    }
                 }
-                else if (dir.length() != 0) {
-                    ret.append(dir);
+                else {
+                	ret.append(af.getHost() + "/" + af.getDir());
                 }
             }
         }

Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2012-06-23 20:40:31 UTC (rev 5812)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2012-06-23 20:41:54 UTC (rev 5813)
@@ -280,7 +280,13 @@
 	}
 
 	protected static String pathOnly(String file) {
-		return new AbsFile(file).getPath();
+	    AbsFile af = new AbsFile(file);
+	    if ("file".equals(af.getProtocol())) {
+	        return af.getPath();
+	    }
+	    else {
+	        return af.getHost() + "/" + af.getPath();
+	    }
 	}
 
 	protected String[] pathOnly(String[] files) {




More information about the Swift-commit mailing list