diff options
author | Timothy Arceri <[email protected]> | 2018-08-16 15:29:06 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2018-08-18 09:20:39 +1000 |
commit | 3f9d8e9c88eb9d95b4637d0b65008cf62527b08b (patch) | |
tree | 0d9205749864f39c8f466c092349f1d66f6e4425 /src/util | |
parent | d0803dea11233ee4df079fbf6bba40e6f6cd2c2b (diff) |
util: better handle program names from wine
For some reason wine will sometimes give us a windows style path
for an application. For example when running the 64bit version
of Rage wine gives a Unix style path, but when running the 32bit
version is gives a windows style path.
If we detect no '/' in the path at all it should be safe to
assume we have a wine application and instead look for a '\'.
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/u_process.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/util/u_process.c b/src/util/u_process.c index 5bf3f56db4e..5e5927678d8 100644 --- a/src/util/u_process.c +++ b/src/util/u_process.c @@ -40,11 +40,18 @@ extern char *program_invocation_name, *program_invocation_short_name; static const char * __getProgramName() { - char * arg = strrchr(program_invocation_name, '/'); - if (arg) - return arg+1; - else - return program_invocation_name; + char * arg = strrchr(program_invocation_name, '/'); + if (arg) + return arg+1; + + /* If there was no '/' at all we likely have a windows like path from + * a wine application. + */ + arg = strrchr(program_invocation_name, '\\'); + if (arg) + return arg+1; + + return program_invocation_name; } # define GET_PROGRAM_NAME() __getProgramName() #elif defined(__CYGWIN__) |