XPCOM writeString错误 [英] XPCOM writeString error

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

问题描述

  //这个函数写入字符串到文件
函数WriteFile(path,string)
{

// import FileUtils.jsm
Components.utils.import(resource:// gre /模块/ FileUtils.jsm);
//声明文件
var file = new FileUtils.File(path);

//声明文件路径
file.initWithPath(path);

//如果存在则移动如果不创建它
if(!file.exists())
{
file.create(file.NORMAL_FILE_TYPE,0666 );
}

var charset ='EUC-JP';
var fileStream = Components.classes ['@ mozilla.org/network/file-output-stream; 1']
.createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(文件,18,0x200,false);
var converterStream =组件
.classes ['@ mozilla.org/intl/converter-output-stream;1']
.createInstance(Components.interfaces.nsIConverterOutputStream);
converterStream.init(fileStream,charset,string.length,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);

//将文件写入位置
converterStream.writeString(\r\\\
+ string);
converterStream.close();
fileStream.close();







$ b但是至于昨天我开始得到这个消息,而不管我尝试在不同的PC上使用哪个浏览器。

  [Exception ...]组件返回失败代码:0x80460003(NS_ERROR_LOSS_OF_SIGNIFICANT_DATA)[nsIConverterOutputStream.writeString]nsresult:0x80460003 NS_ERROR_LOSS_OF_SIGNIFICANT_DATA)location:JS frame :: chrome://imacros/content/iMacros.js :: WriteFile :: line 329data:no](Error code:991)

所以我查了 mozilla开发人员这个错误是什么意思,并发现这一点。

pre $ NS $ ERROR_LOSS_OF_SIGNIFICANT_DATA

NS_ERROR_ILLEGAL_DURING_SHUTDOWN($ 0x8046001E)
一旦应用程序正在执行许多操作关掉。在这种情况下会发生这个错误。

但是我不知道这里有什么错误,因为我没有更改函数代码以任何方式。有人可以解释这个错误吗?

解决方案

我替换了这个

  var charset ='EUC-JP'; 

用这个

  var charset ='UTF8'; 

解决了我的问题。


I am using this function to write text to a file via iMacros addon in FireFox.

//This function writes string into a file
function WriteFile(path,string)
{

//import FileUtils.jsm
Components.utils.import("resource://gre/modules/FileUtils.jsm");
//declare file
var file = new FileUtils.File(path);

//declare file path
file.initWithPath(path);

//if it exists move on if not create it
if (!file.exists())
{
file.create(file.NORMAL_FILE_TYPE, 0666);
}

var charset = 'EUC-JP';
var fileStream = Components.classes['@mozilla.org/network/file-output-stream;1']
.createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(file, 18, 0x200, false);
var converterStream = Components
.classes['@mozilla.org/intl/converter-output-stream;1']
.createInstance(Components.interfaces.nsIConverterOutputStream);
converterStream.init(fileStream, charset, string.length,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);

//write file to location
converterStream.writeString("\r\n"+string);
converterStream.close();
fileStream.close();


}

But as for yesterday I started getting this message, regardless of which browser I tried and on different PC.

[Exception... "Component returned failure code: 0x80460003 (NS_ERROR_LOSS_OF_SIGNIFICANT_DATA) [nsIConverterOutputStream.writeString]"  nsresult: "0x80460003 (NS_ERROR_LOSS_OF_SIGNIFICANT_DATA)"  location: "JS frame :: chrome://imacros/content/iMacros.js :: WriteFile :: line 329"  data: no] (Error code: 991)

So I checked on mozilla developers what does this error mean and found this.

NS_ERROR_LOSS_OF_SIGNIFICANT_DATA (0x80460003)
NS_ERROR_ILLEGAL_DURING_SHUTDOWN (0x8046001E)
Many operations cannot be performed once the application is being shutdown. This error will occur in this situation.

But I can't figure out what is the error here since I didn't change the function code in any way. Can someone interpret this error ?

解决方案

I replaced this

var charset = 'EUC-JP';

with this

var charset = 'UTF8';

and it solved my problems.

这篇关于XPCOM writeString错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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