+ // FAT filesystems, what a drag, we can't tell at the fs level.
+ // ... but we can still invoke 'file' and grep out the good bits, at least.
+ //
+ // open a stream reading 'file /path/to/file' and check output for 'executable'
+ // -- not checking for "ARM" so it can pick up x86 (or whatever native) executables in build environment
+ unsigned char is_executable = 0;
+
+ // popen test
+ {
+ char popenbuf [ FILENAME_MAX ];
+ snprintf ( popenbuf, FILENAME_MAX, "%s %s/%s", MIMETYPE_EXE, g_categories [ ui_category ].fspath, ui_selected -> ref -> title_en );
+
+ FILE *marceau;
+ if ( ! ( marceau = popen ( popenbuf, "r" ) ) ) {
+ return; // error, we need some useful error handling and dialog boxes here
+ }
+
+ if ( fgets ( popenbuf, FILENAME_MAX, marceau ) ) {
+ //printf ( "File test returns: %s\n", popenbuf );
+ if ( strstr ( popenbuf, "executable" ) != NULL ) {
+ is_executable = 1;
+ }
+ }
+
+ pclose ( marceau );
+
+ } // popen test
+
+ if ( ! is_executable ) {
+ fprintf ( stderr, "ERROR: File to invoke is not executable, skipping. (%s)\n", ui_selected -> ref -> title_en );
+ return; // need some error handling here
+ }