mingw path extension fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37592 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2014-01-13 12:43:48 +00:00
parent 7b5ed7128e
commit b426fe64a9
2 changed files with 21 additions and 19 deletions

View file

@ -82,8 +82,13 @@ executablePath(NSFileManager *mgr, NSString *path)
if ([tmp length] == 0)
{
NSEnumerator *e = [[NSTask executableExtensions] objectEnumerator];
NSString *ext = @"EXE";
NSSet *exts;
NSString *ext;
NSEnumerator *e;
exts = [NSTask executableExtensions];
e = [exts objectEnumerator];
ext = @"EXE";
/* Try 'EXE' first, but otherwise iterate through all available
* extensions to find an executable path.
@ -91,9 +96,9 @@ executablePath(NSFileManager *mgr, NSString *path)
do
{
tmp = [path stringByAppendingPathExtension: ext];
if ([mgr isExecutableFileAtPath: path])
if ([mgr isExecutableFileAtPath: tmp])
{
return path;
return tmp;
}
}
while (nil != (ext = [e nextObject]));

View file

@ -733,7 +733,6 @@ pty_slave(const char* name)
*/
- (NSString*) validatedLaunchPath
{
NSFileManager *mgr;
NSString *libs;
NSString *cpu;
NSString *os;
@ -748,7 +747,6 @@ pty_slave(const char* name)
return nil;
}
mgr = [NSFileManager defaultManager];
libs = [NSBundle _library_combo];
os = [NSBundle _gnustep_target_os];
cpu = [NSBundle _gnustep_target_cpu];
@ -773,13 +771,13 @@ pty_slave(const char* name)
full_path = [arch_path stringByAppendingPathComponent: libs];
lpath = [full_path stringByAppendingPathComponent: prog];
if ([mgr isExecutableFileAtPath: lpath] == NO)
if (nil == (lpath = [NSTask executablePath: lpath]))
{
lpath = [arch_path stringByAppendingPathComponent: prog];
if ([mgr isExecutableFileAtPath: lpath] == NO)
if (nil == (lpath = [NSTask executablePath: lpath]))
{
lpath = [base_path stringByAppendingPathComponent: prog];
if ([mgr isExecutableFileAtPath: lpath] == NO)
if (nil == (lpath = [NSTask executablePath: lpath]))
{
/*
* Last resort - if the launch path was simply a program name
@ -792,30 +790,29 @@ pty_slave(const char* name)
}
if (lpath != nil)
{
if ([mgr isExecutableFileAtPath: lpath] == NO)
{
lpath = nil;
}
lpath = [NSTask executablePath: lpath];
}
}
}
}
if (lpath != nil)
{
/* Fix up path by adding any extension required on systems like
* mswindows which don't work by file permission.
*/
lpath = [NSTask executablePath: lpath];
/* Make sure we have a standardised absolute path to pass to execve()
*/
if ([lpath isAbsolutePath] == NO)
{
NSString *current = [mgr currentDirectoryPath];
NSString *current;
current = [[NSFileManager defaultManager] currentDirectoryPath];
lpath = [current stringByAppendingPathComponent: lpath];
}
lpath = [lpath stringByStandardizingPath];
#if defined(__MINGW__)
if ([lpath rangeOfString: @"/"].length > 0)
{
lpath = [lpath stringByReplacingString: @"/" withString: @"\\"];
}
#endif
}
return lpath;
}