diff options
-rwxr-xr-x | make/scripts/java-win32.bat | 5 | ||||
-rwxr-xr-x | make/scripts/runtest-x32.bat | 3 | ||||
-rwxr-xr-x | make/scripts/runtest.sh | 6 | ||||
-rwxr-xr-x | make/scripts/test-win32-smb_share.bat | 24 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 43 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java | 39 |
6 files changed, 91 insertions, 29 deletions
diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index 20952cc..12a95a3 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -13,4 +13,7 @@ set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\test\build\gluegen-test.jar;lib\ echo CP_ALL %CP_ALL%
-%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
+set D_ARGS="-Djogamp.debug.IOUtil"
+REM set D_ARGS="-Djogamp.debug=all"
+
+%J2RE_HOME%\bin\java -classpath %CP_ALL% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
diff --git a/make/scripts/runtest-x32.bat b/make/scripts/runtest-x32.bat index a2238df..a594f4a 100755 --- a/make/scripts/runtest-x32.bat +++ b/make/scripts/runtest-x32.bat @@ -1,5 +1,6 @@ REM scripts\java-win32.bat com.jogamp.common.GlueGenVersion REM scripts\java-win32.bat com.jogamp.common.util.TestVersionInfo REM scripts\java-win32.bat com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter -scripts\java-win32.bat com.jogamp.common.os.TestElfReader01 +REM scripts\java-win32.bat com.jogamp.common.os.TestElfReader01 +scripts\java-win32.bat com.jogamp.common.util.TestIOUtilURIHandling diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 8251995..7651bc5 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -52,7 +52,7 @@ rm -f $LOG #D_ARGS="-Djogamp.debug.Lock" #D_ARGS="-Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.debug.Lock.TraceLock" -#D_ARGS="-Djogamp.debug.IOUtil" +D_ARGS="-Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug=all" function onetest() { @@ -95,8 +95,8 @@ function onetest() { #onetest com.jogamp.common.util.TestRunnableTask01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIOUtil01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIOUtilURICompose 2>&1 | tee -a $LOG -onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG -#onetest com.jogamp.common.util.TestIOUtilURIHandling 2>&1 | tee -a $LOG +#onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG +onetest com.jogamp.common.util.TestIOUtilURIHandling 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestJarUtil 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestValueConversion 2>&1 | tee -a $LOG diff --git a/make/scripts/test-win32-smb_share.bat b/make/scripts/test-win32-smb_share.bat new file mode 100755 index 0000000..5f55583 --- /dev/null +++ b/make/scripts/test-win32-smb_share.bat @@ -0,0 +1,24 @@ +
+set SMB_ROOT=\\risa.goethel.localnet\deployment\test\jogamp
+
+set BLD_SUB=build-win32
+set J2RE_HOME=c:\jre1.7.0_45_x32
+set JAVA_HOME=c:\jdk1.7.0_45_x32
+set ANT_PATH=C:\apache-ant-1.8.2
+
+set PROJECT_ROOT=%SMB_ROOT%\gluegen
+set BLD_DIR=%PROJECT_ROOT%\%BLD_SUB%
+
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH%
+
+set D_ARGS="-Djogamp.debug=all"
+
+set LIB_DIR=
+
+set CP_ALL=.;%BLD_DIR%\gluegen-rt.jar;%PROJECT_ROOT%\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar
+
+echo CP_ALL %CP_ALL%
+
+%J2RE_HOME%\bin\java -classpath %CP_ALL% %D_ARGS% %X_ARGS% com.jogamp.common.GlueGenVersion > java-win.log 2>&1
+tail java-win.log
+
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 2bcb58c..60a0ee0 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -517,6 +517,9 @@ public class IOUtil { * </ul> * </p> * <p> + * Note that a given {@link URI#getAuthority() authority} for <i>file scheme</i>s is preserved to support window's shares. + * </p> + * <p> * Tested w/ unit test <code>com.jogamp.common.util.TestIOUtilURIHandling</code> * </p> * @param uri @@ -531,6 +534,12 @@ public class IOUtil { final boolean isJar = IOUtil.JAR_SCHEME.equals(uriSchema); final URI specificURI = isJar ? JarUtil.getJarSubURI(uri) : uri; final boolean hasJarSubURI = specificURI != uri; + final String authorityS; + { + final String authority = specificURI.getAuthority(); + authorityS = ( null == authority ) ? "" : "//"+authority; + } + if( DEBUG ) { System.err.println("IOUtil.toURL.0: isJAR "+isJar+", hasSubURI "+hasJarSubURI+PlatformPropsImpl.NEWLINE+ "\t, uri "+uri+PlatformPropsImpl.NEWLINE+ @@ -538,6 +547,7 @@ public class IOUtil { "\t ascii -> "+specificURI.toASCIIString()+PlatformPropsImpl.NEWLINE+ "\t ssp -> "+specificURI.getSchemeSpecificPart()+PlatformPropsImpl.NEWLINE+ "\t frag -> "+specificURI.getFragment()+PlatformPropsImpl.NEWLINE+ + "\t auth -> "+authorityS+PlatformPropsImpl.NEWLINE+ /* "//user-info@host:port" */ "\t path -> "+specificURI.getPath()+PlatformPropsImpl.NEWLINE+ "\t path.decoded -> "+decodeFromURI( specificURI.getPath() ) ); } @@ -580,9 +590,9 @@ public class IOUtil { } } if( !hasJarSubURI ) { - urlS = IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+fPathUriS; + urlS = IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+authorityS+fPathUriS; if( DEBUG ) { - System.err.println("IOUtil.toURL.1: fPath "+fPath+PlatformPropsImpl.NEWLINE+ + System.err.println("IOUtil.toURL.1: authorityS "+authorityS+", fPath "+fPath+PlatformPropsImpl.NEWLINE+ "\t -> "+fPathUriS+PlatformPropsImpl.NEWLINE+ "\t -> "+urlS); } @@ -591,9 +601,9 @@ public class IOUtil { } else { final String jarEntry = JarUtil.getJarEntry(uri); final String post = isJar ? IOUtil.JAR_SCHEME_SEPARATOR + jarEntry : ""; - urlS = uriSchema+IOUtil.SCHEME_SEPARATOR+IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+fPathUriS+post; + urlS = uriSchema+IOUtil.SCHEME_SEPARATOR+IOUtil.FILE_SCHEME+IOUtil.SCHEME_SEPARATOR+authorityS+fPathUriS+post; if( DEBUG ) { - System.err.println("IOUtil.toURL.2: fPath "+fPath+PlatformPropsImpl.NEWLINE+ + System.err.println("IOUtil.toURL.2: authorityS "+authorityS+", fPath "+fPath+PlatformPropsImpl.NEWLINE+ "\t -> "+fPathUriS+PlatformPropsImpl.NEWLINE+ "\t, jarEntry "+jarEntry+PlatformPropsImpl.NEWLINE+ "\t, post "+post+PlatformPropsImpl.NEWLINE+ @@ -916,8 +926,8 @@ public class IOUtil { return patternSpaceEnc.matcher(s).replaceAll(" "); } - private static final Pattern patternSingleBS = Pattern.compile("\\\\{1,}"); - private static final Pattern patternSingleFS = Pattern.compile("/{1,}"); + private static final Pattern patternSingleBS = Pattern.compile("\\\\{1}"); + private static final Pattern patternSingleFS = Pattern.compile("/{1}"); /** * Encodes file path characters not complying w/ RFC 2396 and the {@link URI#URI(String)} ctor. @@ -961,8 +971,8 @@ public class IOUtil { * Then it processes the <code>path</code> if {@link File#separatorChar} <code> != '/'</code> * as follows: * <ul> - * <li>drop a starting slash</li> * <li>slash -> backslash</li> + * <li>drop a starting single backslash</li> * </ul> * </p> * @see #decodeFromURI(String) @@ -971,7 +981,7 @@ public class IOUtil { final String path = IOUtil.decodeFromURI(uriPath); if( !File.separator.equals("/") ) { final String r = patternSingleFS.matcher(path).replaceAll("\\\\"); - if( r.startsWith("\\") ) { + if( r.startsWith("\\") && !r.startsWith("\\\\") ) { // '\\\\' denotes UNC hostname, which shall not be cut-off return r.substring(1); } else { return r; @@ -982,15 +992,26 @@ public class IOUtil { /** * If <code>uri</code> is a <i>file scheme</i>, - * implementation returns the decoded {@link URI#getPath()} via {@link #decodeURIToFilePath(String)}, - * otherwise it returns the {@link URI#toASCIIString()} encoded URI. + * implementation returns the decoded <i>[ "//"+{@link URI#getAuthority()} ] + {@link URI#getPath()}</i> via {@link #decodeURIToFilePath(String)}. + * <p> + * Otherwise it returns the {@link URI#toASCIIString()} encoded URI. + * </p> * * @see #decodeFromURI(String) * @see #decodeURIToFilePath(String) */ public static String decodeURIIfFilePath(final URI uri) { if( IOUtil.FILE_SCHEME.equals( uri.getScheme() ) ) { - return decodeURIToFilePath( uri.getPath() ); + final String authorityS; + { + final String authority = uri.getAuthority(); + if( null == authority ) { + authorityS = ""; + } else { + authorityS = "//"+authority; + } + return decodeURIToFilePath(authorityS+uri.getPath()); + } } return uri.toASCIIString(); } diff --git a/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java b/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java index ecf950b..efd7030 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java +++ b/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java @@ -84,6 +84,9 @@ public class TestIOUtilURIHandling extends JunitTracer { new String[] {"jar:file:/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class", "jar:file:/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class" }, + new String[] {"jar:file://filehost/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class", + "jar:file://filehost/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class" }, + /** Not possible, '#' is fragment in URI new String[] {"jar:file:/gluegen/%23/gluegen-rt.jar!/", "jar:file:/gluegen/#/gluegen-rt.jar!/" }, */ @@ -111,6 +114,12 @@ public class TestIOUtilURIHandling extends JunitTracer { new String[] {"jar:file:/C:/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class", "jar:file:/C:/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class" }, + new String[] {"jar:file:///C:/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class", + "jar:file:/C:/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class" }, + + new String[] {"jar:file://filehost/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class", + "jar:file://filehost/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class" }, + /** Not possible, '#' is fragment in URI new String[] {"jar:file:/C:/gluegen/%23/gluegen-rt.jar!/", "jar:file:/C:/gluegen/#/gluegen-rt.jar!/" }, */ @@ -160,6 +169,11 @@ public class TestIOUtilURIHandling extends JunitTracer { "file:/C:/gluegen/build-x86_64 öä lala/gluegen-rt.jar", "C:\\gluegen\\build-x86_64 öä lala\\gluegen-rt.jar"}, + new String[] {"\\\\filehost\\gluegen\\build-x86_64 öä lala\\gluegen-rt.jar", + "file://filehost/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar", + "file://filehost/gluegen/build-x86_64 öä lala/gluegen-rt.jar", + "\\\\filehost\\gluegen\\build-x86_64 öä lala\\gluegen-rt.jar"}, + /* No support for '#' fragment in URI path ! new String[] {"C:/gluegen/#/gluegen-rt.jar", "file:/C:/gluegen/%23/gluegen-rt.jar", @@ -364,22 +378,21 @@ public class TestIOUtilURIHandling extends JunitTracer { final File file = new File(fileSource); { final URI uri0 = file.toURI(); - System.err.println("uri.string: "+uri0.toString()); - System.err.println("uri.ascii : "+uri0.toASCIIString()); + System.err.println("uri0.string: "+uri0.toString()); + System.err.println("uri0.ascii : "+uri0.toASCIIString()); } - final URI uri0 = IOUtil.toURISimple(file); - System.err.println("uri.string: "+uri0.toString()); - System.err.println("uri.ascii : "+uri0.toASCIIString()); - showURI(uri0); - showURL(uri0.toURL()); + final URI uri1 = IOUtil.toURISimple(file); + System.err.println("uri1.string: "+uri1.toString()); + System.err.println("uri1.ascii : "+uri1.toASCIIString()); + showURI(uri1); + showURL(uri1.toURL()); - final URL actualUrl = IOUtil.toURL(uri0); + final URL actualUrl = IOUtil.toURL(uri1); final String actualUrlS = actualUrl.toExternalForm(); - final String actualUrlPathS = actualUrl.getPath(); - final String actualFilePathS = IOUtil.decodeURIToFilePath( actualUrlPathS ); - final boolean equalsFilePath = fileExpected.equals(actualFilePathS); - System.err.println("actual____url-path: "+actualUrlPathS); - System.err.println("actual___file-path: "+actualFilePathS); + final String actualFileS = IOUtil.decodeURIIfFilePath(uri1); + final boolean equalsFilePath = fileExpected.equals(actualFileS); + System.err.println("actual_______uri : "+actualUrlS); + System.err.println("actual___file-path: "+actualFileS); System.err.println("expected_path: "+fileExpected+" - "+(equalsFilePath?"OK":"ERROR")); final boolean equalsDecUri = uriDecExpected.equals(actualUrlS); System.err.println("actual_______uri: "+actualUrlS); |