Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#15000 closed defect (worksforme)

Wrong behavior of IsFileExecutable

Reported by: LocutusOfBorg Owned by:
Priority: normal Milestone:
Component: base Version: 2.8.12
Keywords: Cc:
Blocked By: Blocking:
Patch: no


Hi, I found an ugly behavior of IsFileExecutable function on linux.

I was trying to figure out why boinc's code doesn't work and I found this piece of code
(this is only the linux part)
wxFileDialog picker(this, _("Applications to add"),


if (picker.ShowModal() != wxID_OK) return;


for (i=appNames.Count()-1; i>=0; --i) {

wxString directory = picker.GetDirectory();
wxFileName fn(directory, appNames[i]);

if (!fn.IsOk()
!fn.IsFileExecutable()) {

errmsg.Printf(_("'%s' is not an executable application."), appNames[i].c_str());
wxGetApp().SafeMessageBox(errmsg, _("Add Exclusive App"), wxOK | wxICON_EXCLAMATION, this);



basically this code ask you to add an executable file to a list, performs the check if the file is really executable and removes it if not.
The problem is that if I chose from the picker something like "/bin/ls" the IsFileExecutable returns that is not an executable file, while it is.

If I copy /bin/ls into my home it works like a charm even if I chose /bin/ls and not /home/locutus/ls.

I cannot figure out why files in my home are correctly detected and not the files on other directories...

Where am I wrong?

Change History (3)

comment:1 Changed 8 years ago by vadz

  • Component changed from wxGTK to base
  • Resolution set to worksforme
  • Status changed from new to closed

With the following simple test:

#include <wx/init.h>
#include <wx/filename.h>
#include <wx/log.h>

int main(int argc, char **argv)
    if ( argc != 2 ) {
        fprintf(stderr, "Usage: %s <file-name>\n", argv[0]);
        return 1;

    wxInitializer init;
    if ( !init.IsOk() ) {
        fprintf(stderr, "Failed to initialize wxWidgets.\n");
        return 2;

    wxFileName fn(argv[1]);
    wxLogMessage("File \"%s\" is %sexecutable.",
                 fn.GetFullPath(), fn.IsFileExecutable() ? "" : "not ");

    return 0;

this works for me:

% g++ -Wall wxbt.cpp `~/build/wx-gtkud/wx-config --cxxflags --libs base` && ./a.out /bin/ls
13:27:23: File "/bin/ls" is executable.

with wx 2.9.4.

Please retest with 2.9 if you can and if the problem is still reproducible there, please reopen the ticket with a way allowing us to reproduce it.

comment:2 Changed 8 years ago by LocutusOfBorg

31 minutes for troubleshooting the problem and giving back an answer with a working code!!!

Simply awesome support!

I admit I didn't test with 2.9.x/3.x versions because debian doesn't wants to include them in the repository since they aren't stable at this time, so I'll go through the new version ASA debian starts packaging them.

Anyway thanks for your time, I'll build 2.9.4 from scratch, try to reproduce the problem and send back a feedback.

I'll try too to export a patch for 2.8.12 for making it work, since I think this bug has been fixed in 2.9 branch

comment:3 Changed 8 years ago by LocutusOfBorg

Works like a charm with 2.9.4, I'll try to extract a patch :)

thanks for your help!

Note: See TracTickets for help on using tickets.