diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider')
-rw-r--r-- | files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html new file mode 100644 index 0000000000..20d094eaf3 --- /dev/null +++ b/files/zh-cn/mozilla/tech/xpcom/reference/interface/nsidirectoryserviceprovider/index.html @@ -0,0 +1,65 @@ +--- +title: nsIDirectoryServiceProvider +slug: Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryServiceProvider +translation_of: Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryServiceProvider +--- +<p></p><div style="border: solid #ddd 2px; margin-bottom: 12px;"> +<div style="background: #eee; padding: 2px;"><code><a href="https://dxr.mozilla.org/mozilla-central/source/xpcom/io/nsIDirectoryService.idl" rel="custom">xpcom/io/nsIDirectoryService.idl</a></code><span style="text-align: right; float: right;"><a href="/zh-CN/docs/Interfaces/About_Scriptable_Interfaces" style="color: #00cc00; font-weight: 700;">脚本化</a></span></div> +<span style="padding: 4px 2px;"> + +本接口是目录服务用于得到文件位置的函数。 +</span> + +<div style="background: #eee; padding: 2px;"> +继承于: <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsISupports" title="">nsISupports</a></code> +<span style="text-align: right; float: right;">最后修改于Gecko 1.7 </span></div> +</div><p></p> +<p><code>nsIDirectoryServiceProvider</code>.</p> +<h2 id="Method_overview" name="Method_overview">方法概览</h2> +<table class="standard-table"> + <tbody> + <tr> + <td><code>nsIFile <a href="#getFile()">getFile</a>(in string prop, out PRBool persistent);</code></td> + </tr> + </tbody> +</table> +<h2 id="Methods" name="Methods">方法</h2> +<h3 id="getFile()" name="getFile()">getFile()</h3> +<p>The Directory Service calls this method when it gets the first request for a prop or on every request if the prop is not persistent.</p> +<pre class="eval">nsIFile getFile( + in string prop, + out PRBool persistent +); +</pre> +<h6 id="Parameters" name="Parameters">Parameters</h6> +<dl> + <dt> + <code>prop</code></dt> + <dd> + The symbolic name of the file.</dd> + <dt> + <code>persistent</code></dt> + <dd> + <code>true</code> if the returned file will be cached by Directory Service. Subsequent requests for this prop will bypass the provider and use the cache. <code>false</code> if the provider will be asked for this prop each time it is requested.</dd> +</dl> +<h6 id="Return_value" name="Return_value">Return value</h6> +<p>The <code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile" title="">nsIFile</a></code> represented by the property.</p> +<h2 id="Example" name="Example">示例</h2> +<p>This code creates a global, read-only string called <code>currDir</code> with the value of the current working directory.</p> +<pre class="eval"> __defineGetter__("currDir", + function getCurrDir() { + return Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIDirectoryServiceProvider) + .getFile("CurWorkD",{}).path; + }); +</pre> +<p>Test it with to see the magic happen.</p> +<pre class="eval"> alert(currDir); +</pre> +<h2 id="See_also" name="See_also">参见</h2> +<ul> + <li><a href="/en/nsDirectoryService" title="en/nsDirectoryService">nsDirectoryService</a></li> + <li><code><a href="/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDirectoryService" title="">nsIDirectoryService</a></code></li> + <li>(译注)其它目录服务关键字见<a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsDirectoryServiceDefs.h" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsDirectoryServiceDefs.h">nsDirectoryServiceDefs.h</a></li> +</ul> +<p>Additionally, see <a class="external" href="http://mb.eschew.org/16.php#sub_16.5.2">section 16.5.2</a> of the <a class="external" href="http://mb.eschew.org/">Rapid Application Development with Mozilla</a> book for instructions on how to get the <strong>current working directory</strong> and the <strong>process binary directory</strong>, among other things.</p> |