From 4c835f0337674a0181c43f448d44d961e27b2f54 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * A file scheme path, i.e. path following
* Otherwise the default {@link URL} translation {@link URI#toURL()} is being used.
+ *
* The following cases are considered:
* file:/
.
+ * Converts an {@link URI} to an {@link URL} while using a non encoded path.
+ * file:
, is converted as follows:
+ *
+ File file = new File( {@link #decodeFromURI(String) decodeFromURI}( specificURI.getPath() ) );
+ String uriFilePath = {@link #encodeFilePathToURI(String) encodeFilePathToURI}( file.getPath() );
+ *
+ * above conversion results in a decoded file path appropriate to be used by subsequent file i/o operations (JarFile, zip, ..).
+ *
*
* new File(uri).getPath()
.
- *
- * Processes input filePath if {@link File#separatorChar} != '/'
+ * Implementation processes the filePath
if {@link File#separatorChar} != '/'
* as follows:
*
+ * Note that this method does not perform space encoding, + * which can be utilized via {@link #encodeToURI(String)}. + *
+ *
* Even though Oracle's JarURLStreamHandler can handle backslashes and
* erroneous URIs w/ e.g. Windows file 'syntax', other may not (Netbeans).
* See Bug 857 - http://jogamp.org/bugzilla/show_bug.cgi?id=857
*
+ * Implementation decodes the space-encoding path={@link #decodeFromURI(String) decodeFromURI}(uriPath)
.
+ *
+ * Then it processes the path
if {@link File#separatorChar} != '/'
+ * as follows:
+ *
uri
is a file scheme,
+ * implementation returns the decoded {@link URI#getPath()} via {@link #decodeURIToFilePath(String)},
+ * otherwise it returns the {@link URI#toASCIIString()} encoded URI.
+ *
+ * @see #decodeFromURI(String)
+ * @see #decodeURIToFilePath(String)
+ */
+ public static String decodeURIIfFilePath(final URI uri) {
+ if( IOUtil.FILE_SCHEME.equals( uri.getScheme() ) ) {
+ return decodeURIToFilePath( uri.getPath() );
+ }
+ return uri.toASCIIString();
+ }
+
/**
* Returns the connected URLConnection, or null if not url is not available
*/
@@ -1206,7 +1268,7 @@ public class IOUtil {
// 1) java.io.tmpdir/jogamp
if( null == tempRootExec && isStringSet(java_io_tmpdir) ) {
- if( Platform.OSType.MACOS == Platform.getOSType() ) {
+ if( Platform.OSType.MACOS == PlatformPropsImpl.OS_TYPE ) {
// Bug 865: Safari >= 6.1 [OSX] May employ xattr on 'com.apple.quarantine' on 'PluginProcess.app'
// We attempt to fix this issue _after_ gluegen native lib is loaded, see JarUtil.fixNativeLibAttribs(File).
tempRootExec = getSubTempDir(new File(java_io_tmpdir), tmpSubDir, false /* executable */, "tempX1");
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java
index d22d441..77f1a84 100644
--- a/src/java/com/jogamp/common/util/JarUtil.java
+++ b/src/java/com/jogamp/common/util/JarUtil.java
@@ -287,7 +287,7 @@ public class JarUtil {
if(0 >= uriS1.lastIndexOf(".jar")) {
throw new IllegalArgumentException("No Jar name in <"+classJarURI+">");
}
- final String uriS2 = IOUtil.encodeToURI(uriS1);
+ final String uriS2 = IOUtil.encodeToURI(uriS1); // 'new URI(String)' will not encode space!
if(DEBUG) {
System.err.println("getJarSubURI res: "+classJarURI+" -> "+uriS0+" -> "+uriS1+" -> "+uriS2);
}
--
cgit v1.2.3