mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
when looking for executables in windows path, try all executable file extensions
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37571 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
373e26b33e
commit
41a59dc49e
1 changed files with 48 additions and 20 deletions
|
@ -307,28 +307,56 @@ AbsolutePathOfExecutable(NSString *path, BOOL atLaunch)
|
|||
{
|
||||
NSString *extension = [path pathExtension];
|
||||
|
||||
/* Also add common executable extensions on windows */
|
||||
if (extension == nil || [extension length] == 0)
|
||||
/* Also try adding any executable extensions on windows
|
||||
*/
|
||||
if ([extension length] == 0)
|
||||
{
|
||||
NSString *wpath;
|
||||
static NSSet *executable = nil;
|
||||
NSString *wpath;
|
||||
NSEnumerator *e;
|
||||
NSString *s;
|
||||
|
||||
wpath = [prefix stringByAppendingPathExtension: @"exe"];
|
||||
if ([mgr isExecutableFileAtPath: wpath])
|
||||
{
|
||||
result = [wpath stringByStandardizingPath];
|
||||
break;
|
||||
}
|
||||
wpath = [prefix stringByAppendingPathExtension: @"com"];
|
||||
if ([mgr isExecutableFileAtPath: wpath])
|
||||
{
|
||||
result = [wpath stringByStandardizingPath];
|
||||
break;
|
||||
}
|
||||
wpath = [prefix stringByAppendingPathExtension: @"cmd"];
|
||||
if ([mgr isExecutableFileAtPath: wpath])
|
||||
{
|
||||
result = [wpath stringByStandardizingPath];
|
||||
break;
|
||||
if (nil == executable)
|
||||
{
|
||||
NSMutableSet *m;
|
||||
|
||||
/* Get PATHEXT environment variable and split apart on ';'
|
||||
*/
|
||||
e = [[[[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"PATHEXT"]
|
||||
componentsSeparatedByString: @";"] objectEnumerator];
|
||||
|
||||
m = [NSMutableSet set];
|
||||
while (nil != (s = [e nextObject]))
|
||||
{
|
||||
/* We don't have a '.' in a file extension, but the
|
||||
* environment variable probably does ... fix it.
|
||||
*/
|
||||
s = [s stringByTrimmingSpaces];
|
||||
if ([s hasPrefix: @"."])
|
||||
{
|
||||
s = [s substringFromIndex: 1];
|
||||
}
|
||||
if ([s length] > 0)
|
||||
{
|
||||
[m addObject: s];
|
||||
}
|
||||
}
|
||||
/* Make sure we at least have the EXE extension.
|
||||
*/
|
||||
[m addObject: @"EXE"];
|
||||
ASSIGNCOPY(executable, m);
|
||||
}
|
||||
|
||||
e = [executable objectEnumerator];
|
||||
while (nil != (s = [e nextObject]))
|
||||
{
|
||||
wpath = [prefix stringByAppendingPathExtension: s];
|
||||
if ([mgr isExecutableFileAtPath: wpath])
|
||||
{
|
||||
result = [wpath stringByStandardizingPath];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue