Commits

Meikel Brandmeyer committed 3af0864

Add simple path relativization utility

Comments (0)

Files changed (1)

clojuresque-common/src/main/groovy/clojuresque/Util.groovy

 
         new ByteArrayInputStream(outWriter.toString().getBytes("UTF-8"))
     }
+
+    static relativizePath(baseDir, absolutePath) {
+        def baseDirS      = baseDir.path
+        def absolutePathS = absolutePath.path
+
+        (absolutePathS.startsWith(baseDirS)) ?
+            absolutePathS.substring(baseDirS.length() + 1) :
+            null
+    }
 }