From 26cfabd41cc90fb426f343efc3fa4e8773792f19 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 22 May 2009 17:16:24 +0000 Subject: [PATCH] fix for bundle loading on wndows when we don't have the dll path extension git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28292 72102866-910b-0410-8b05-ffd578937521 --- Source/NSBundle.m | 21 +++++++++++++++++++-- Source/NSFileManager.m | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/NSBundle.m b/Source/NSBundle.m index e581adaca..5c96e7f4d 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -320,7 +320,7 @@ bundle_object_name(NSString *path, NSString* executable) path = [path stringByAppendingPathComponent: gnustep_target_dir]; path1 = [path stringByAppendingPathComponent: name]; path = [path stringByAppendingPathComponent: library_combo]; - path2 = [path stringByAppendingPathComponent: executable]; + path2 = [path stringByAppendingPathComponent: name]; if ([mgr isReadableFileAtPath: path2] == YES) return path2; @@ -328,7 +328,24 @@ bundle_object_name(NSString *path, NSString* executable) return path1; else if ([mgr isReadableFileAtPath: path0] == YES) return path0; - return path2; +#if defined(__MINGW32__) + /* If we couldn't find the binary, and we are on windows, and the name + * has no path extension, then let's try looking for a dll. + */ + if ([name pathExtension] == nil) + { + if ([mgr isReadableFileAtPath: + [path2 stringByAppendingPathExtension: @"dll"]] == YES) + return [path2 stringByAppendingPathExtension: @"dll"]; + else if ([mgr isReadableFileAtPath: + [path1 stringByAppendingPathExtension: @"dll"]] == YES) + return [path1 stringByAppendingPathExtension: @"dll"]; + else if ([mgr isReadableFileAtPath: + [path0 stringByAppendingPathExtension: @"dll"]] == YES) + return [path0 stringByAppendingPathExtension: @"dll"]; + } +#endif + return path0; } /* Construct a path from components */ diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 9dc070f02..418f1a32b 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -2021,6 +2021,10 @@ static NSStringEncoding defaultEncoding; #if defined(__MINGW32__) - (const GSNativeChar*) fileSystemRepresentationWithPath: (NSString*)path { + if (path != nil && [path rangeOfString: @"/"].length > 0) + { + path = [path stringByReplacingString: @"/" withString: @"\\"]; + } return (const GSNativeChar*)[path cStringUsingEncoding: NSUnicodeStringEncoding]; }