Try to lock each profile. If already in use will throw NS_ERROR_FILE_ACCESS_DENIED
var inUse;
try{
var profunlock = profile.lock(null);
inUse = false;
profunlock.unlock();
}
catch(e){
inUse = true;
}
Domanda
I'm trying to get a list of currently open profiles. This code below lists alll profiles regardless of open:
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)
}
Soluzione
Try to lock each profile. If already in use will throw NS_ERROR_FILE_ACCESS_DENIED
var inUse;
try{
var profunlock = profile.lock(null);
inUse = false;
profunlock.unlock();
}
catch(e){
inUse = true;
}