Search code examples
macosfirefoxfirefox-addon

Interface of nsILocalFileMac


I found this thing on MDN called nsILocalFileMac I couldn't make too much sense of it. However there is this thing called "alias" and "followLinks". Is this synonymous with a "shortcut" or ".lnk" file on Windows?

If it is, how can I use this interface to make an "alias"?


Solution

  • Yes, in Unix systems you can make a shortcut like this, they are called symlink or alias files:

    Cu.import('resource://gre/modules/osfile.jsm');
    var pathToTarget = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, 'Firefox.app');
    var pathToAlias = OS.Path.join(OS.Constants.Path.desktopDir, 'ff.link'); //extension is .link, the file must not exist or unixErrno 17 ocurs
    var promise_alias = OS.File.unixSymLink(pathToTarget, pathToAlias)
    promise_alias.then(
      function(aVal) {
        console.log('Promise Fullfilled - promise_alias - ', aVal);
      },
      function(aReason) {
        console.error('Promise Rejected - promise_alias - ', aReason);
      }
    );