nsIFileProtocolHandler 编辑
netwerk/protocol/file/nsIFileProtocolHandler.idl
Scriptable This interface provides methods to convert between nsIFile
and nsIURI
. It also provides access to Internet shortcuts stored on the host operating system's file system. Inherits from: nsIProtocolHandler
Last changed in Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)Method overview
nsIFile getFileFromURLSpec(in AUTF8String url); |
AUTF8String getURLSpecFromActualFile(in nsIFile file); |
AUTF8String getURLSpecFromDir(in nsIFile file); |
AUTF8String getURLSpecFromFile(in nsIFile file); |
nsIURI newFileURI(in nsIFile aFile); |
nsIURI readURLFile(in nsIFile file); |
Methods
getFileFromURLSpec()
Converts the URL string into the corresponding nsIFile
if possible. A local file will be created if the URL string begins with file://
.
nsIFile getFileFromURLSpec( in AUTF8String url );
Parameters
url
- The url string to convert.
Return value
A reference to a new nsIFile
object.
getURLSpecFromActualFile()
Converts the nsIFile
to the corresponding URL string. Should only be called on files which are not directories. Otherwise identical to getURLSpecFromFile()
, but is usually more efficient.
Warning: This restriction may not be enforced at runtime!
AUTF8String getURLSpecFromActualFile( in nsIFile file );
Parameters
file
- The
nsIFile
to convert.
Return value
Corresponding url string. The resulting string may contain URL-escaped characters.
getURLSpecFromDir()
Converts the nsIFile
to the corresponding URL string. Should only be called on files which are directories. Otherwise identical to getURLSpecFromFile()
, but is usually more efficient. WARNING: This restriction may not be enforced at runtime!
AUTF8String getURLSpecFromDir( in nsIFile file );
Parameters
file
- The
nsIFile
to convert.
Return value
Corresponding url string. The resulting string may contain URL-escaped characters.
getURLSpecFromFile()
Converts the nsIFile
to the corresponding URL string. If the nsIFile
is a local file, then the result will be a file://
URL string. The resulting string may contain URL-escaped characters.
Note: Callers should use getURLSpecFromActualFile()
if possible, for performance reasons.
AUTF8String getURLSpecFromFile( in nsIFile file );
Parameters
file
- The
nsIFile
to convert.
Return value
Corresponding url string. The resulting string may contain URL-escaped characters.
newFileURI()
This method constructs a new file URI.
nsIURI newFileURI( in nsIFile aFile );
Parameters
aFile
- The
nsIFile
to convert.
Return value
A reference to a new nsIURI
object.
readURLFile()
Takes a local file and tries to interpret it as an Internet shortcut (for example .url files on windows).
nsIURI readURLFile( in nsIFile file );
Parameters
file
- The
nsIFile
to read.
Return value
The nsIURI
the file refers to.
Exceptions thrown
NS_ERROR_NOT_AVAILABLE
- The OS does not support such files.
NS_ERROR_NOT_AVAILABLE
- The file is not an Internet shortcut.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论