From e65a2ecdb64cce2048f09b363c12a02438e0c18c Mon Sep 17 00:00:00 2001 From: nova Date: Mon, 6 Jul 2026 23:53:49 +0200 Subject: [PATCH] executing an executable exe now properly executing through wine --- interactions.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/interactions.c b/interactions.c index b184636..8f74ae6 100644 --- a/interactions.c +++ b/interactions.c @@ -198,10 +198,34 @@ void move_right(){ skip_if_empty_dir + char *cmd = NULL; + + if (mid_dir.current_file->file_type & FILE_TYPE_DIR) { change_dir(mid_dir.current_file->file_name); } else if (mid_dir.current_file->file_type & FILE_TYPE_EXEC) { - char *cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR, mid_dir.current_file->file_name); + + /* if an .exe is executable, this branch will trigger as expected, + * however since executing an .exe without wine causes a exec format error, we should check if the program you tried to access is that + * if an .exe is not executable, it will get to the top else branch, then hit the comparison in the file extension area, and succeed also. + * that is unless the user removed wine out of the file_extension_default_cmd, + * in which case im going to assume wine isnt installed anyways as that would require: + * a. thought on my end in how to catch wine being removed in the config + * b. the user having deliberately changed the default config (good, thats why they are easily configurable) + * c. if wine is not installed on the system, executing an .exe would fail regardless of via direct execution or through wine */ + char *extension = mid_dir.current_file->file_name; + while (extension <= mid_dir.current_file->file_name + strlen(mid_dir.current_file->file_name)) { + if (*extension == '.') { + break; + } + extension++; + } + + if (strcmp(extension, ".exe") == 0) { + cmd = parse_cmd("wine ./"SETTINGS_COMMAND_REPLACE_STR, mid_dir.current_file->file_name); + } else { + cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR, mid_dir.current_file->file_name); + } ignore_return(system(cmd)); } else { char *mime = get_mimetype(mid_dir.current_file); @@ -258,8 +282,8 @@ void move_right(){ } } status &= ~STATUS_MOVE_RIGHT_MATCH; - free(cmd); } + free(cmd); status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY); }