Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Last active February 24, 2016 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/feeec1776c6ee4254a34 to your computer and use it in GitHub Desktop.
Save Noitidart/feeec1776c6ee4254a34 to your computer and use it in GitHub Desktop.
_ff-addon-snippet-showFileInOSExplorer - Opens the file or directory in operating systems file explorer, uses XPCOM.
// rev3 - https://gist.github.com/Noitidart/feeec1776c6ee4254a34
function showFileInOSExplorer(aNsiFile, aDirPlatPath, aFileName) {
// can pass in aNsiFile
if (aNsiFile) {
//http://mxr.mozilla.org/mozilla-release/source/browser/components/downloads/src/DownloadsCommon.jsm#533
// opens the directory of the aNsiFile
if (aNsiFile.isDirectory()) {
aNsiFile.launch();
} else {
aNsiFile.reveal();
}
} else {
var cNsiFile = new FileUtils.File(aDirPlatPath);
if (!aFileName) {
// its a directory
cNsiFile.launch();
} else {
cNsiFile.append(aFileName);
cNsiFile.reveal();
}
}
}
@Noitidart
Copy link
Author

README

Rev1

  • Untested

Rev2

  • Fixed typo bug

Rev3

  • Fixed bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment