Firefox nsIFileInputStream不起作用 [英] Firefox nsIFileInputStream not working

查看:58
本文介绍了Firefox nsIFileInputStream不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我理解这段代码的问题:

Can anyone help me understand the problem with this chunk of code:

var file = Components.classes["@mozilla.org/file/local;1"]
           .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("\\\\.\\pipe\\MyPipe");
		
// WRITE
var myRequest = "BlaBla";
var outputStream = Components.classes["@mozilla.org/network/file-outputstream;1"]
                   .createInstance(Components.interfaces.nsIFileOutputStream);
outputStream.init(file, 0x02 | 0x08, -1, 0);
outputStream.write(myRequest, myRequest.length);

// READ
var result;
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
                    .createInstance(Components.interfaces.nsIFileInputStream);
inputStream.init(file, -1, 0, 0);
inputStream.read(result);



您可能已经猜到了,我正在尝试打开命名管道,发送一些信息,并收到一些信息。发送部分有效。但是,它在阅读部分出于某种原因停止了我什么都没有!



有什么想法吗?



更新:我只知道其行为奇怪的原因,由于某种原因我无法添加 InputStream OutputStream 到同一个管道。当我尝试添加输出流并写入 ONLY 时,它似乎工作得很好。但是,只要我添加 InputStream ,它就会因某种原因而失速。



任何想法为什么会发生这种情况?


As you might have already guessed, I am trying to open a named pipe, send some information, and receive some info. The sending part works. However, it stops for some reason at the reading part and i get nothing!

Any ideas?

UPDATE: I just figured out the reason why its acting strange, for some reason I can't add an InputStream and an OutputStream to the same pipe. When i try adding an outputstream and writing to it ONLY, it seems to work just fine. However, as soon as i add my InputStream, it stalls for some reason.

Any ideas Why this occurs?

推荐答案

我刚刚意识到这是一个未处理的 BUG Mozilla 。每当您尝试打开 InputStream 以从 NamedPipe 中读取时,它会抛出(NS_ERROR_FAILURE)EXCEPTION



希望他们尽快修复它!
I just came to realize that this is an unhandled BUG in Mozilla. Whenever you try to open an InputStream for reading from a NamedPipe, it throws a (NS_ERROR_FAILURE) EXCEPTION.

Hope they fix it soon though!


这篇关于Firefox nsIFileInputStream不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆