Mercurial > projects > dwt-linux
comparison dwt/browser/AppFileLocProvider.d @ 286:44258e0b6687
More fixes for xpcom
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 10:11:58 -0700 |
parents | 93409d9838c5 |
children | b0bd1789106b |
comparison
equal
deleted
inserted
replaced
280:e72345914350 | 286:44258e0b6687 |
---|---|
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * John Reimer <terminal.node@gmail.com> | 11 * John Reimer <terminal.node@gmail.com> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 | |
14 module dwt.browser.AppFileLocProvider; | 13 module dwt.browser.AppFileLocProvider; |
15 | 14 |
15 import tango.sys.Environment; | |
16 import tango.text.Util; | |
17 | |
16 import dwt.dwthelper.utils; | 18 import dwt.dwthelper.utils; |
17 | 19 |
18 import dwt.internal.Compatibility; | 20 import dwt.internal.Compatibility; |
19 | 21 import dwt.internal.mozilla.XPCOM; |
22 import dwt.internal.mozilla.XPCOMObject; | |
20 import dwt.internal.mozilla.nsEmbedString; | 23 import dwt.internal.mozilla.nsEmbedString; |
21 import dwt.internal.mozilla.nsID; | 24 import dwt.internal.mozilla.nsID; |
22 import dwt.internal.mozilla.nsIDirectoryService; | 25 import dwt.internal.mozilla.nsIDirectoryServiceProvider; |
26 import dwt.internal.mozilla.nsIDirectoryServiceProvider2; | |
23 import dwt.internal.mozilla.nsIFile; | 27 import dwt.internal.mozilla.nsIFile; |
24 import dwt.internal.mozilla.nsILocalFile; | 28 import dwt.internal.mozilla.nsILocalFile; |
25 import dwt.internal.mozilla.nsISupports; | 29 import dwt.internal.mozilla.nsISupports; |
26 | 30 |
27 class AppFileLocProvider : nsISupports, nsIDirectoryServiceProvider2 | 31 class AppFileLocProvider : directoryServiceProvider2 { |
28 { | 32 int refCount = 0; |
29 // XPCOMObject supports; | 33 String mozillaPath, profilePath; |
30 // XPCOMObject directoryServiceProvider; | |
31 // XPCOMObject directoryServiceProvider2; | |
32 nsrefcnt _refCount = 0; | |
33 String mozillaPath, profilePath; | |
34 String[] pluginDirs; | 34 String[] pluginDirs; |
35 bool isXULRunner; | 35 bool isXULRunner; |
36 | 36 |
37 static String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ | 37 static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ |
38 static String CHROME_DIR = "chrome"; //$NON-NLS-1$ | 38 static final String CHROME_DIR = "chrome"; //$NON-NLS-1$ |
39 static String COMPONENTS_DIR = "components"; //$NON-NLS-1$ | 39 static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$ |
40 static String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ | 40 static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ |
41 static String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ | 41 static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ |
42 static String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ | 42 static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ |
43 static String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ | 43 static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ |
44 static String USER_PLUGINS_DIR = ".mozilla" + SEPARATOR_OS + "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ | 44 static final String USER_PLUGINS_DIR = ".mozilla" ~ SEPARATOR_OS ~ "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ |
45 static String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ | 45 static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ |
46 | 46 |
47 AppFileLocProvider (String path) { | 47 this (String path) { |
48 mozillaPath = path + SEPARATOR_OS; | 48 mozillaPath = path ~ SEPARATOR_OS;f |
49 createCOMInterfaces (); | 49 } |
50 } | 50 |
51 | 51 int AddRef () { |
52 int AddRef () | 52 refCount++; |
53 { | 53 return refCount; |
54 refCount++; | 54 } |
55 return refCount; | 55 |
56 } | 56 int QueryInterface (nsID* riid, int void** ppvObject) { |
57 | 57 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
58 nsresult QueryInterface ( nsIID* riid, void** ppvObject) | 58 |
59 { | 59 if (*riid == nsISupports.IID)) { |
60 if (riid is null || ppvObject is null) | 60 *ppvObject = cast(void*)cast(nsISupports)this; |
61 return NS_ERROR_NO_INTERFACE; | 61 AddRef (); |
62 | 62 return XPCOM.NS_OK; |
63 if (riid == nsISupports.IID) | 63 } |
64 { | 64 if (*riid == nsIDirectoryServiceProvider.IID) { |
65 *ppvObject =cast(void*)cast(nsISupports)this; | 65 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; |
66 AddRef (); | 66 AddRef (); |
67 return NS_OK; | 67 return XPCOM.NS_OK; |
68 } | 68 } |
69 | 69 if (*riid == nsIDirectoryServiceProvider2.IID) { |
70 if (riid == nsIDirectoryServiceProvider.IID) | 70 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; |
71 { | 71 AddRef (); |
72 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; | 72 return XPCOM.NS_OK; |
73 AddRef (); | 73 } |
74 return NS_OK; | 74 |
75 } | 75 *ppvObject = null; |
76 | 76 return XPCOM.NS_ERROR_NO_INTERFACE; |
77 if (riid == nsDirectoryServiceProvider2.IID) { | 77 } |
78 *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; | 78 |
79 AddRef (); | 79 int Release () { |
80 return NS_OK; | 80 refCount--; |
81 } | 81 if (refCount is 0) return 0; |
82 | 82 return refCount; |
83 *ppvObject = null; | 83 } |
84 return NS_ERROR_NO_INTERFACE; | |
85 } | |
86 | |
87 nsrefcnt Release () | |
88 { | |
89 _refCount--; | |
90 if (_refCount is 0) | |
91 return 0; | |
92 return _refCount; | |
93 } | |
94 | 84 |
95 void setProfilePath (String path) { | 85 void setProfilePath (String path) { |
96 profilePath = path; | 86 profilePath = path; |
97 if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ | 87 if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ |
98 int /*long*/[] result = new int /*long*/[1]; | 88 nsILocalFile result; |
99 nsEmbedString pathString = new nsEmbedString (path); | 89 scope auto nsEmbedString pathString = new nsEmbedString (path); |
100 int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); | 90 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &result); |
101 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 91 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
102 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); | 92 if (result is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
103 pathString.dispose (); | 93 |
104 | 94 rc = result.Create (nsILocalFile.DIRECTORY_TYPE, 0700); |
105 nsILocalFile file = new nsILocalFile (result [0]); | |
106 rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700); | |
107 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 95 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
108 file.Release (); | 96 file.Release (); |
109 } | 97 } |
110 } | 98 } |
111 | 99 |
112 /* nsIDirectoryServiceProvider2 */ | 100 /* nsIDirectoryServiceProvider2 */ |
113 | 101 |
114 int getFiles (int /*long*/ prop, int /*long*/ _retval) { | 102 nsresult GetFiles (char* prop, nsISimpleEnumerator* _retval) { |
115 int size = XPCOM.strlen (prop); | 103 String propertyName = tango.stdc.stringz.fromStringz( prop ); |
116 byte[] bytes = new byte[size]; | |
117 XPCOM.memmove (bytes, prop, size); | |
118 String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); | |
119 String[] propertyValues = null; | 104 String[] propertyValues = null; |
120 | 105 |
121 if (propertyName.equals (XPCOM.NS_APP_PLUGINS_DIR_LIST)) { | 106 if (propertyName == XPCOM.NS_APP_PLUGINS_DIR_LIST) { |
122 if (pluginDirs is null) { | 107 if (pluginDirs is null) { |
123 int index = 0; | 108 int index = 0; |
124 /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ | 109 /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ |
125 int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_PLUGIN_PATH, true)); | 110 String value = Environment.get (XPCOM.MOZILLA_PLUGIN_PATH); |
126 if (ptr !is 0) { | 111 if (ptr !is null) { |
127 int length = C.strlen (ptr); | 112 if (value.length > 0) { |
128 byte[] buffer = new byte[length]; | |
129 C.memmove (buffer, ptr, length); | |
130 String value = new String (MozillaDelegate.mbcsToWcs (null, buffer)); | |
131 if (value.length () > 0) { | |
132 String separator = System.getProperty ("path.separator"); // $NON-NLS-1$ | 113 String separator = System.getProperty ("path.separator"); // $NON-NLS-1$ |
133 Vector segments = new Vector (); | 114 foreach (segment; delimiter(value, separator)) |
134 int start, end = -1; | 115 pluginDirs ~= segment; |
135 do { | |
136 start = end + 1; | |
137 end = value.indexOf (separator, start); | |
138 String segment; | |
139 if (end is -1) { | |
140 segment = value.substring (start); | |
141 } else { | |
142 segment = value.substring (start, end); | |
143 } | |
144 if (segment.length () > 0) segments.addElement (segment); | |
145 } while (end !is -1); | |
146 int segmentsSize = segments.size (); | |
147 pluginDirs = new String [segmentsSize + 2]; | |
148 for (index = 0; index < segmentsSize; index++) { | |
149 pluginDirs[index] = (String)segments.elementAt (index); | |
150 } | |
151 } | 116 } |
152 } | 117 } |
153 if (pluginDirs is null) { | 118 if (pluginDirs is null) { |
154 pluginDirs = new String[2]; | 119 pluginDirs = new String[2]; |
155 } | 120 } |
156 | 121 |
157 /* set the next value to the GRE path + "plugins" */ | 122 /* set the next value to the GRE path + "plugins" */ |
158 pluginDirs[index++] = mozillaPath + PLUGINS_DIR; | 123 pluginDirs ~= mozillaPath ~ PLUGINS_DIR; |
159 | 124 |
160 /* set the next value to the home directory + "/.mozilla/plugins" */ | 125 /* set the next value to the home directory + "/.mozilla/plugins" */ |
161 pluginDirs[index++] = System.getProperty("user.home") + SEPARATOR_OS + USER_PLUGINS_DIR; | 126 pluginDirs ~= System.getProperty("user.home") ~ SEPARATOR_OS ~ USER_PLUGINS_DIR; |
162 } | 127 } |
163 propertyValues = pluginDirs; | 128 propertyValues = pluginDirs; |
164 } | 129 } |
165 | 130 |
166 XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); | 131 *_retval = null; |
132 //XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); | |
167 if (propertyValues !is null) { | 133 if (propertyValues !is null) { |
168 int /*long*/[] result = new int /*long*/[1]; | 134 nsILocalFile localFile; |
135 nsIFile file; | |
169 nsISupports[] files = new nsISupports [propertyValues.length]; | 136 nsISupports[] files = new nsISupports [propertyValues.length]; |
170 int index = 0; | 137 int index = 0; |
171 for (int i = 0; i < propertyValues.length; i++) { | 138 for (int i = 0; i < propertyValues.length; i++) { |
172 nsEmbedString pathString = new nsEmbedString (propertyValues[i]); | 139 scope auto pathString = new nsEmbedString (propertyValues[i]); |
173 int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); | 140 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); |
174 if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) { | 141 if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) { |
175 /* value appears to be a valid pathname */ | 142 /* value appears to be a valid pathname */ |
176 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 143 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
177 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); | 144 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
178 | 145 |
179 nsILocalFile localFile = new nsILocalFile (result[0]); | 146 rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, &(cast(void*)file)); |
180 result[0] = 0; | |
181 rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); | |
182 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 147 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
183 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); | 148 if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
184 localFile.Release (); | 149 localFile.Release (); |
185 | 150 |
186 nsIFile file = new nsIFile (result[0]); | 151 files[index++] = cast(nsISupports)file; |
187 files[index++] = file; | |
188 } | 152 } |
189 pathString.dispose (); | |
190 result[0] = 0; | |
191 } | 153 } |
192 | 154 |
193 if (index < propertyValues.length) { | 155 if (index < propertyValues.length) { |
194 /* there were some invalid values so remove the trailing empty array slots */ | 156 /* there were some invalid values so remove the trailing empty array slots */ |
195 nsISupports[] temp = new nsISupports [index]; | 157 nsISupports[] temp = new nsISupports [index]; |
196 System.arraycopy (files, 0, temp, 0, index); | 158 System.arraycopy (files, 0, temp, 0, index); |
197 files = temp; | 159 files = temp; |
198 } | 160 } |
199 | 161 |
200 SimpleEnumerator enumerator = new SimpleEnumerator (files); | 162 auto enumerator = new SimpleEnumerator (files); |
201 enumerator.AddRef (); | 163 enumerator.AddRef (); |
202 XPCOM.memmove (_retval, new int /*long*/[] {enumerator.getAddress ()}, C.PTR_SIZEOF); | 164 *_retval = cast(nsISimpleEnumerator)enumerator; |
203 return XPCOM.NS_OK; | 165 return XPCOM.NS_OK; |
204 } | 166 } |
205 | 167 |
206 return XPCOM.NS_ERROR_FAILURE; | 168 return XPCOM.NS_ERROR_FAILURE; |
207 } | 169 } |
208 | 170 |
209 /* nsIDirectoryServiceProvider implementation */ | 171 /* nsIDirectoryServiceProvider implementation */ |
210 | 172 |
211 int getFile(int /*long*/ prop, int /*long*/ persistent, int /*long*/ _retval) { | 173 nsresult GetFile(char* prop, PRBool* persistent, nsIFile* _retval) { |
212 int size = XPCOM.strlen (prop); | 174 String propertyName = tango.stdc.stringz.fromStringz( prop ); |
213 byte[] bytes = new byte[size]; | |
214 XPCOM.memmove (bytes, prop, size); | |
215 String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); | |
216 String propertyValue = null; | 175 String propertyValue = null; |
217 | 176 |
218 if (propertyName.equals (XPCOM.NS_APP_HISTORY_50_FILE)) { | 177 if (propertyName == (XPCOM.NS_APP_HISTORY_50_FILE)) { |
219 propertyValue = profilePath + HISTORY_FILE; | 178 propertyValue = profilePath ~ HISTORY_FILE; |
220 } else if (propertyName.equals (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { | 179 } else if (propertyName == (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { |
221 propertyValue = profilePath + MIMETYPES_FILE; | 180 propertyValue = profilePath ~ MIMETYPES_FILE; |
222 } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_FILE)) { | 181 } else if (propertyName == (XPCOM.NS_APP_PREFS_50_FILE)) { |
223 propertyValue = profilePath + PREFERENCES_FILE; | 182 propertyValue = profilePath ~ PREFERENCES_FILE; |
224 } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_DIR)) { | 183 } else if (propertyName == (XPCOM.NS_APP_PREFS_50_DIR)) { |
225 propertyValue = profilePath; | 184 propertyValue = profilePath; |
226 } else if (propertyName.equals (XPCOM.NS_APP_USER_CHROME_DIR)) { | 185 } else if (propertyName == (XPCOM.NS_APP_USER_CHROME_DIR)) { |
227 propertyValue = profilePath + CHROME_DIR; | 186 propertyValue = profilePath ~ CHROME_DIR; |
228 } else if (propertyName.equals (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { | 187 } else if (propertyName == (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { |
229 propertyValue = profilePath; | 188 propertyValue = profilePath; |
230 } else if (propertyName.equals (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { | 189 } else if (propertyName == (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { |
231 propertyValue = profilePath + LOCALSTORE_FILE; | 190 propertyValue = profilePath ~ LOCALSTORE_FILE; |
232 } else if (propertyName.equals (XPCOM.NS_APP_CACHE_PARENT_DIR)) { | 191 } else if (propertyName == (XPCOM.NS_APP_CACHE_PARENT_DIR)) { |
233 propertyValue = profilePath; | 192 propertyValue = profilePath; |
234 } else if (propertyName.equals (XPCOM.NS_OS_HOME_DIR)) { | 193 } else if (propertyName == (XPCOM.NS_OS_HOME_DIR)) { |
235 propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ | 194 propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ |
236 } else if (propertyName.equals (XPCOM.NS_OS_TEMP_DIR)) { | 195 } else if (propertyName == (XPCOM.NS_OS_TEMP_DIR)) { |
237 propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ | 196 propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ |
238 } else if (propertyName.equals (XPCOM.NS_GRE_DIR)) { | 197 } else if (propertyName == (XPCOM.NS_GRE_DIR)) { |
239 propertyValue = mozillaPath; | 198 propertyValue = mozillaPath; |
240 } else if (propertyName.equals (XPCOM.NS_GRE_COMPONENT_DIR)) { | 199 } else if (propertyName == (XPCOM.NS_GRE_COMPONENT_DIR)) { |
241 propertyValue = mozillaPath + COMPONENTS_DIR; | 200 propertyValue = mozillaPath ~ COMPONENTS_DIR; |
242 } else if (propertyName.equals (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { | 201 } else if (propertyName == (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { |
243 propertyValue = mozillaPath; | 202 propertyValue = mozillaPath; |
244 } else if (propertyName.equals (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { | 203 } else if (propertyName == (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { |
245 propertyValue = mozillaPath; | 204 propertyValue = mozillaPath; |
246 } else if (propertyName.equals (XPCOM.NS_XPCOM_COMPONENT_DIR)) { | 205 } else if (propertyName == (XPCOM.NS_XPCOM_COMPONENT_DIR)) { |
247 propertyValue = mozillaPath + COMPONENTS_DIR; | 206 propertyValue = mozillaPath ~ COMPONENTS_DIR; |
248 } else if (propertyName.equals (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { | 207 } else if (propertyName == (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { |
249 propertyValue = mozillaPath; | 208 propertyValue = mozillaPath; |
250 } else if (propertyName.equals (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { | 209 } else if (propertyName == (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { |
251 /* | 210 /* |
252 * Answering a value for this property causes problems in Mozilla versions | 211 * Answering a value for this property causes problems in Mozilla versions |
253 * < 1.7. Unfortunately this property is queried early enough in the | 212 * < 1.7. Unfortunately this property is queried early enough in the |
254 * Browser creation process that the Mozilla version being used is not | 213 * Browser creation process that the Mozilla version being used is not |
255 * yet determined. However it is known if XULRunner is being used or not. | 214 * yet determined. However it is known if XULRunner is being used or not. |
259 * in the future to be >= 1.7 then this value can always be answered. | 218 * in the future to be >= 1.7 then this value can always be answered. |
260 */ | 219 */ |
261 if (isXULRunner) propertyValue = profilePath; | 220 if (isXULRunner) propertyValue = profilePath; |
262 } | 221 } |
263 | 222 |
264 XPCOM.memmove (persistent, new int[] {1}, 4); /* PRBool */ | 223 *persistent = true; /* PRBool */ |
265 XPCOM.memmove (_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); | 224 *_retval = null; |
266 if (propertyValue !is null && propertyValue.length () > 0) { | 225 if (propertyValue !is null && propertyValue.length > 0) { |
267 int /*long*/[] result = new int /*long*/[1]; | 226 nsILocalFile localFile; |
268 nsEmbedString pathString = new nsEmbedString (propertyValue); | 227 scope auto pathString = new nsEmbedString (propertyValue); |
269 int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); | 228 int rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &(cast(void*)localFile)); |
270 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 229 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
271 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); | 230 if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); |
272 pathString.dispose (); | |
273 | 231 |
274 nsILocalFile localFile = new nsILocalFile (result [0]); | 232 nsIFile file; |
275 result[0] = 0; | 233 rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, &(cast(void*)file)); |
276 rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); | 234 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
277 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); | 235 if (file is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); | 236 |
279 | 237 *_retval = file; |
280 XPCOM.memmove (_retval, new int /*long*/[] {result[0]}, C.PTR_SIZEOF); | |
281 localFile.Release (); | 238 localFile.Release (); |
282 return XPCOM.NS_OK; | 239 return XPCOM.NS_OK; |
283 } | 240 } |
284 | 241 |
285 return XPCOM.NS_ERROR_FAILURE; | 242 return XPCOM.NS_ERROR_FAILURE; |