Skip to content

Instantly share code, notes, and snippets.

@uggrock
Created March 22, 2013 21:39
Show Gist options
  • Select an option

  • Save uggrock/5224979 to your computer and use it in GitHub Desktop.

Select an option

Save uggrock/5224979 to your computer and use it in GitHub Desktop.
exports.promptDirectorySelector = function promptDirectorySelector(worker) {
console.debug("Opening directory selection dialog...");
try {
var window = require("window/utils").getMostRecentBrowserWindow();
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Directory Selection", Ci.nsIFilePicker.modeGetFolder);
var result = fp.show();
if (result === Ci.nsIFilePicker.returnOK) {
worker.postMessage({
"command": "selectDirectory",
"success": true,
"content": fp.file.path
});
}
} catch(ex) {
worker.postMessage({
"command": "selectDirectory",
"success": false
});
console.error("Directory selection failed "+ex);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment