Identify if a file is an executable

Hi all:

I need to identify if a file is or not executable. Of course, I’m not talking about checking the +x flag in the attributes, but about checking the content and detecting if it is an ELF binary, an script (because it starts with #!)… something that I can execute by calling spawn. Is there something in glib that does this?


g_file_query_info() then g_file_info_get_content_type() and compare it against a content type like application/x-sharedlib using g_content_type_equals().

You might want to use the asynchronous versions of g_file_query_info() if you don’t want to block your main loop.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.