summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2008-03-06 17:10:11 +0000
committerGrant Gayed <ggayed>2008-03-06 17:10:11 +0000
commit3db02dc28ac07e7e831b2fd12ee9b4de50e194bd (patch)
treeef01c22b4f2d93db6f71ed7e9817ed6191ba793a /bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java
parent6577c0688be998241ba8bf70063dfd0779e8e30e (diff)
downloadeclipse.platform.swt-3db02dc28ac07e7e831b2fd12ee9b4de50e194bd.tar.gz
eclipse.platform.swt-3db02dc28ac07e7e831b2fd12ee9b4de50e194bd.tar.xz
eclipse.platform.swt-3db02dc28ac07e7e831b2fd12ee9b4de50e194bd.zip
205796
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java
index 0a211faf7e..7232f75572 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java
@@ -29,6 +29,10 @@ public final class Program {
String name;
byte[] fsRef;
+ static final String PREFIX_HTTP = "http://"; //$NON-NLS-1$
+ static final String PREFIX_HTTPS = "https://"; //$NON-NLS-1$
+ static final String PREFIX_FILE = "file://"; //$NON-NLS-1$
+
/**
* Prevents uninitialized instances from being created outside the package.
*/
@@ -356,13 +360,21 @@ public static Program [] getPrograms () {
public static boolean launch (String fileName) {
if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
int rc = -1;
- if (fileName.indexOf(':') == -1) fileName = "file://" + fileName;
+ char[] unescapedChars = new char[] {'%'};
+ if (fileName.indexOf(':') == -1) {
+ fileName = PREFIX_FILE + fileName;
+ } else {
+ String lowercaseName = fileName.toLowerCase ();
+ if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) {
+ unescapedChars = new char[] {'%', '#'};
+ }
+ }
char[] chars = new char[fileName.length()];
fileName.getChars(0, chars.length, chars, 0);
int str = OS.CFStringCreateWithCharacters(0, chars, chars.length);
if (str != 0) {
- int unscapedStr = OS.CFStringCreateWithCharacters(0, new char[]{'%'}, 1);
- int escapedStr = OS.CFURLCreateStringByAddingPercentEscapes(OS.kCFAllocatorDefault, str, unscapedStr, 0, OS.kCFStringEncodingUTF8);
+ int unescapedStr = OS.CFStringCreateWithCharacters(0, unescapedChars, unescapedChars.length);
+ int escapedStr = OS.CFURLCreateStringByAddingPercentEscapes(OS.kCFAllocatorDefault, str, unescapedStr, 0, OS.kCFStringEncodingUTF8);
if (escapedStr != 0) {
int url = OS.CFURLCreateWithString(OS.kCFAllocatorDefault, escapedStr, 0);
if (url != 0) {
@@ -371,7 +383,7 @@ public static boolean launch (String fileName) {
}
OS.CFRelease(escapedStr);
}
- if (unscapedStr != 0) OS.CFRelease(unscapedStr);
+ if (unescapedStr != 0) OS.CFRelease(unescapedStr);
OS.CFRelease(str);
}
return rc == OS.noErr;
@@ -404,13 +416,21 @@ public boolean execute (String fileName) {
if (fileName.length() == 0) {
rc = OS.LSOpenApplication(params, null);
} else {
- if (fileName.indexOf(':') == -1) fileName = "file://" + fileName;
+ char[] unescapedChars = new char[] {'%'};
+ if (fileName.indexOf(':') == -1) {
+ fileName = PREFIX_FILE + fileName;
+ } else {
+ String lowercaseName = fileName.toLowerCase ();
+ if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) {
+ unescapedChars = new char[] {'%', '#'};
+ }
+ }
char[] chars = new char[fileName.length()];
fileName.getChars(0, chars.length, chars, 0);
int str = OS.CFStringCreateWithCharacters(0, chars, chars.length);
if (str != 0) {
- int unscapedStr = OS.CFStringCreateWithCharacters(0, new char[]{'%'}, 1);
- int escapedStr = OS.CFURLCreateStringByAddingPercentEscapes(OS.kCFAllocatorDefault, str, unscapedStr, 0, OS.kCFStringEncodingUTF8);
+ int unescapedStr = OS.CFStringCreateWithCharacters(0, unescapedChars, unescapedChars.length);
+ int escapedStr = OS.CFURLCreateStringByAddingPercentEscapes(OS.kCFAllocatorDefault, str, unescapedStr, 0, OS.kCFStringEncodingUTF8);
if (escapedStr != 0) {
int urls = OS.CFArrayCreateMutable(OS.kCFAllocatorDefault, 1, 0);
if (urls != 0) {
@@ -423,7 +443,7 @@ public boolean execute (String fileName) {
}
OS.CFRelease(escapedStr);
}
- if (unscapedStr != 0) OS.CFRelease(unscapedStr);
+ if (unescapedStr != 0) OS.CFRelease(unescapedStr);
OS.CFRelease(str);
}
}