nsIFileInputStream 编辑

netwerk/base/nsIFileStreams.idlScriptable An input stream that allows you to read from a file. Inherits from: nsIInputStream Last changed in Gecko 1.7

Method overview

void init(in nsIFile file, in long ioFlags, in long perm, in long behaviorFlags);

Constants

ConstantValueDescription
DELETE_ON_CLOSE1<<1If this is set, the file will be deleted by the time the stream is closed. It may be removed before the stream is closed if it is possible to delete it and still read from it. If OPEN_ON_READ is defined, and the file was recreated after the first delete, the file will be deleted again when it is closed again.
CLOSE_ON_EOF1<<2If this is set, the file will close automatically when the end of the file is reached.
REOPEN_ON_REWIND1<<3If this is set, the file will be reopened whenever Seek(0) occurs. If the file is already open and the seek occurs, it will happen naturally. (The file will only be reopened if it is closed for some reason.)
DEFER_OPEN1<<4If this is set, the file will be opened (i.e., a call to PR_Open() done) only when we do an actual operation on the stream, or more specifically, when one of the following is called:
  • Seek()
  • Tell()
  • Available()
  • Read()
  • ReadLine()

DEFER_OPEN is useful if we use the stream on a background thread, so that the opening and possible stating of the file happens there as well.

Note: Using this flag results in the file not being opened during the call to init. This means that any errors that might happen when this flag is not set would happen during the first read. Also, the file is not locked when init is called, so it might be deleted before we try to read from it.

Methods

init()

void init(
  in nsIFile file,
  in long ioFlags,
  in long perm,
  in long behaviorFlags
);
Parameters
file
File to read from (must QI to nsILocalFile)
ioFlags
The file status flags define how the file is accessed. See PR_Open documentation for more details. If set to -1 the file will be opened in default mode (PR_RDONLY).
perm
File mode bits are described in the PR_Open documentation. If set to -1 the default value 0 will be used.
behaviorFlags
Flags specifying various behaviors of the class (see enumerations in the class).

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:79 次

字数:4504

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文