nsIDirectoryServiceProvider
From MDC
Used by Directory Service to get file locations.
Contents |
nsIDirectoryServiceProvider is defined in xpcom/io/nsIDirectoryService.idl. It is scriptable and
has been frozen since Mozilla 1.8.
Inherits from: nsISupports
[edit] Method overview
nsIFile getFile(in string prop, out PRBool persistent);
|
[edit] Methods
[edit] getFile()
Directory Service calls this when it gets the first request for a prop or on every request if the prop is not persistent.
nsIFile getFile(
in string prop,
out PRBool persistent
);
[edit] Parameters
- prop
- The symbolic name of the file.
- persistent
true- The returned file will be cached by Directory Service. Subsequent requests for this prop will bypass the provider and use the cache.false- The provider will be asked for this prop each time it is requested.
[edit] Return value
The nsIFile represented by the property.
[edit] See Also
Additionally, see section 16.5.2 of the Rapid Application Development with Mozilla book for instructions on how to get the current working directory and the process binary directory, among other things.
Or have a look at this JavaScript code:
__defineGetter__("currDir",
function getCurrDir() {
return Components.classes["@mozilla.org/filedirectory_service;1"]
.getService(Components.interfaces.nsIDirectoryServiceProvider)
.getFile("CurWorkD",{}).path;
});
The above code creates a global, read-only string called currDir with the value of the current working directory. Test it with
alert(currDir);
to see the magic happen.