Firefox addon 当前打开的所有配置文件的列表

Firefox addon 当前打开的所有配置文件的列表,firefox-addon,user-profile,Firefox Addon,User Profile,我正在尝试获取当前打开的配置文件列表。下面的代码列出了所有L配置文件,无论打开的是什么: var tps = Cc['@mozilla.org/toolkit/profile-service;1'].createInstance(Ci.nsIToolkitProfileService); //toolkitProfileService var profileList = tps.profiles; while (profileList.hasMoreElements()) {

我正在尝试获取当前打开的配置文件列表。下面的代码列出了所有L配置文件,无论打开的是什么:

var tps = Cc['@mozilla.org/toolkit/profile-service;1'].createInstance(Ci.nsIToolkitProfileService); //toolkitProfileService

var profileList = tps.profiles;
     while (profileList.hasMoreElements()) {
       var profile = profileList.getNext().QueryInterface(Ci.nsIToolkitProfile);
         console.info(profile)
     }

尝试锁定每个配置文件。如果已在使用,将抛出
NS\u错误\u文件\u访问\u被拒绝

var-inUse;
试一试{
var profulk=profile.lock(null);
因纽斯=假;
profilock.unlock();
}
捕获(e){
因纽斯=真;
}

好主意,但是这个锁定过程是同步的吗?还是异步?或者它是同步的,但速度非常快?我用相关的代码片段更新了答案。这是同步操作,但我不明白为什么会很贵。很酷,非常感谢,伙计!!:)为什么我们不测试e是否为ns\u错误\u文件\u访问\u被拒绝,我们将如何做?我们会怎么做呢?
e.name=='ns\u error\u file\u access\u denied'
?这个锁定/解锁解决方案看起来像是一个黑客,因为我们必须在之后运行解锁功能。仍然对其他解决方案持开放态度:)但我接受了你的答案,感谢manIt,这不是一个黑客行为,每个Gecko应用程序都会检测到该配置文件是否已经在使用。对于异常代码,
e.result==Components.results.NS\u ERROR\u FILE\u ACCESS\u DENIED