mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
mingw fixup for executable files
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37567 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f89c8939a4
commit
6f23a9f315
2 changed files with 51 additions and 4 deletions
|
@ -1,3 +1,9 @@
|
|||
2014-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m:
|
||||
On mingw a file is executable if its extension is in the list
|
||||
provided by the PATHEXT environment variable.
|
||||
|
||||
2014-01-08 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Source/NSValueTransformer (+valueTransformerForName:): Fixed to
|
||||
|
|
|
@ -1654,6 +1654,7 @@ static NSStringEncoding defaultEncoding;
|
|||
#if defined(__MINGW__)
|
||||
{
|
||||
DWORD res;
|
||||
NSString *ext;
|
||||
|
||||
res = GetFileAttributesW(lpath);
|
||||
|
||||
|
@ -1661,10 +1662,50 @@ static NSStringEncoding defaultEncoding;
|
|||
{
|
||||
return NO;
|
||||
}
|
||||
// TODO: Actually should check all extensions in env var PATHEXT
|
||||
if ([[[path pathExtension] lowercaseString] isEqualToString: @"exe"])
|
||||
{
|
||||
return YES;
|
||||
|
||||
ext = [[path pathExtension] uppercaseString];
|
||||
if ([ext length] > 0)
|
||||
{
|
||||
static NSSet *executable = nil;
|
||||
|
||||
if (nil == executable)
|
||||
{
|
||||
NSMutableSet *m;
|
||||
NSEnumerator *e;
|
||||
NSString *s;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
if (nil != [executable member: ext])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
/* FIXME: On unix, directory accessible == executable, so we simulate that
|
||||
here for Windows. Is there a better check for directory access? */
|
||||
|
|
Loading…
Reference in a new issue