[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in [NSBundle _absolutePathOfExecutable]
From: |
Michael Scheibler |
Subject: |
Bug in [NSBundle _absolutePathOfExecutable] |
Date: |
Wed, 03 Jan 2001 15:23:25 +0100 |
Original code:
#if defined(__WIN32__)
/* Also add common executable extensions on windows */
if ([path pathExtension] == nil)
{
NSString *wpath;
wpath = [prefix stringByAppendingPathExtension: @"exe"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
wpath = [prefix stringByAppendingPathExtension: @"com"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
wpath = [prefix stringByAppendingPathExtension: @"cmd"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
}
}
#endif
In line 3:
[NSString pathExtension] never returns nil, but @"".
Correct implementation:
#if defined(__WIN32__)
{
NSString *ext = [path pathExtension];
/* Also add common executable extensions on windows */
if (ext == nil || [ext length] == 0)
{
NSString *wpath;
wpath = [prefix stringByAppendingPathExtension: @"exe"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
wpath = [prefix stringByAppendingPathExtension: @"com"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
wpath = [prefix stringByAppendingPathExtension: @"cmd"];
if ([mgr isExecutableFileAtPath: wpath])
return [wpath stringByStandardizingPath];
}
}
#endif
Michael
- Bug in [NSBundle _absolutePathOfExecutable],
Michael Scheibler <=