- String name = f.getName();
- // FEATURE: This is ugly.. maybe we should do a file(1) type check
- executable = name.endsWith(".mips") || name.endsWith(".sh");
+ boolean _executable = false;
+ // FEATURE: This might be too expensive
+ try {
+ FileInputStream fis = new FileInputStream(f);
+ switch(fis.read()) {
+ case '\177': _executable = fis.read() == 'E' && fis.read() == 'L' && fis.read() == 'F'; break;
+ case '#': _executable = fis.read() == '!';
+ }
+ fis.close();
+ } catch(IOException e) { /* ignore */ }
+ executable = _executable;