From bd72d40781caf40c2148cdc7990218af44750c76 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Wed, 27 Nov 2013 20:29:40 +0100
Subject: IOUtil: Add comments to slashify args @ caller; Use validated File @
 IOUtil.toURISimple ; DEBUG: stdout -> stderr

Add comments to slashify(..) arguments for better documentation.

+++

Use validated File @ IOUtil.toURISimple(..):
    slashify(file, true, isDirectory)
to
    slashify(new File(path).getAbsolutePath(), true, isDirectory)

i.e. same w/ above variant and determine absolute path via File instance.

+++

DEBUG: stdout -> stderr
---
 src/java/com/jogamp/common/util/IOUtil.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'src/java/com/jogamp/common/util/IOUtil.java')

diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java
index 537c3e9..15fb5ab 100644
--- a/src/java/com/jogamp/common/util/IOUtil.java
+++ b/src/java/com/jogamp/common/util/IOUtil.java
@@ -313,7 +313,7 @@ public class IOUtil {
      * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
      */
     public static URI toURISimple(File file) throws URISyntaxException {
-        return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true, file.isDirectory())), null);
+        return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true /* startWithSlash */, file.isDirectory() /* endWithSlash */)), null);
     }
 
     /**
@@ -321,8 +321,8 @@ public class IOUtil {
      * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
      * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI
      */
-    public static URI toURISimple(String protocol, String file, boolean isDirectory) throws URISyntaxException {
-        return new URI(protocol, null, encodeToURI(slashify(file, true, isDirectory)), null);
+    public static URI toURISimple(String protocol, String path, boolean isDirectory) throws URISyntaxException {
+        return new URI(protocol, null, encodeToURI(slashify(new File(path).getAbsolutePath(), true /* startWithSlash */, isDirectory /* endWithSlash */)), null);
     }
 
     /**
@@ -412,7 +412,7 @@ public class IOUtil {
      * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
      */
     public static String getBasename(String fname) throws URISyntaxException {
-        fname = slashify(fname, false, false);
+        fname = slashify(fname, false /* startWithSlash */, false /* endWithSlash */);
         int lios = fname.lastIndexOf('/');  // strip off dirname
         if(lios>=0) {
             fname = fname.substring(lios+1);
@@ -425,7 +425,7 @@ public class IOUtil {
      * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code>
      */
     public static String getDirname(String fname) throws URISyntaxException {
-        fname = slashify(fname, false, false);
+        fname = slashify(fname, false /* startWithSlash */, false /* endWithSlash */);
         int lios = fname.lastIndexOf('/');  // strip off dirname
         if(lios>=0) {
             fname = fname.substring(0, lios+1);
@@ -487,7 +487,7 @@ public class IOUtil {
         uriS = uriS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':'
 
         if( DEBUG ) {
-            System.out.println("getJarURIDirname res: "+uriS);
+            System.err.println("getJarURIDirname res: "+uriS);
         }
         return uriS;
     }
@@ -726,7 +726,7 @@ public class IOUtil {
         if (baseLocation != null) {
             final File file = new File(baseLocation, relativeFile);
             // Handle things on Windows
-            return slashify(file.getPath(), false, false);
+            return slashify(file.getPath(), false /* startWithSlash */, false /* endWithSlash */);
         }
         return null;
     }
-- 
cgit v1.2.3