XUL allows to detect if a file is executable (Windows batch, Unix script, regular executable binary file) simply using the nsIFile::isExecutable method.
I’ve found a workaround in ViewSourceWith since 0.0.8.2 version.
The solution requires a brief technical explanation.
MacOSX uses the so called CFBundle files, these files are stored inside a directory that resides under a standard path:
where LEAD_PATH should be for example /Application and APP_NAME should be for example Firefox
So the Firefox bundle can be found in /Application/Firefox.app/Contents/MacOS/Info.plist
Info.plist is a standard XML file containing many attributes, the CFBundleExecutable points to the executable file name.
The example below shows the content for Firefox Info.plist
So the real executable file is /Application/Firefox.app/Contents/MacOS/firefox-bin
ViewSourceWith contains a function that digs inside MacOSX to find the real executale file.
Initially I wrote the code treating Info.plist like a DOM document but at end I used a regular expression as shown below:
var pListText = ... // contains the Info.plist text
re = /\<key\>CFBundleExecutable\<\/key\>[ \t\n\v\r]*\<string\>[ \t\n\v\r]*(.*)[ \t\n\v\r]*\<\/string\>/
m = pListText.match(re);
the_real_exe = m;
Apple has many API to access to properties without open manually the Info.plist but to use them I need
- a C compiler for Mac
- write native code to use inside firefox extension
Instead, accessing directly to xml file I simplified the development.
You can find the code written for ViewSourceWith in SVN repository.
Other details about this problem can be found on ViewSourceWith FAQ page.