mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
guess what caller meant when they give us bad path name
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26197 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f5f2219ee7
commit
4b6bd491a1
3 changed files with 85 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-03-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSBundle.m Make better guess at what the caller meant when
|
||||
they give us a non-absolute path name on mingw.
|
||||
|
||||
2008-03-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNull.m: Make result of description method match MacOSX
|
||||
|
|
|
@ -1231,8 +1231,39 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
|||
{
|
||||
NSWarnMLog(@"NSBundle -initWithPath: requires absolute path names, "
|
||||
@"given '%@'", path);
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
if ([path length] > 0 &&
|
||||
([path characterAtIndex: 0]=='/' || [path characterAtIndex: 0]=='\\'))
|
||||
{
|
||||
NSString *root;
|
||||
unsigned length;
|
||||
|
||||
/* The path has a leading path separator, so we try assuming
|
||||
* that it's a path on the current filesystem, and append it
|
||||
* to the filesystem root.
|
||||
*/
|
||||
root = [[NSFileManager defaultManager] currentDirectoryPath];
|
||||
length = [root length];
|
||||
root = [root stringByDeletingLastPathComponent];
|
||||
while ([root length] != length)
|
||||
{
|
||||
length = [root length];
|
||||
root = [root stringByDeletingLastPathComponent];
|
||||
}
|
||||
path = [root stringByAppendingPathComponent: path];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Try appending to the current working directory.
|
||||
*/
|
||||
path = [[[NSFileManager defaultManager] currentDirectoryPath]
|
||||
stringByAppendingPathComponent: path];
|
||||
}
|
||||
#else
|
||||
path = [[[NSFileManager defaultManager] currentDirectoryPath]
|
||||
stringByAppendingPathComponent: path];
|
||||
stringByAppendingPathComponent: path];
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,8 +1,48 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
int main ()
|
||||
{
|
||||
static unsigned char bytes[9] = {'\355', '\264', '\200', '\346', '\224', '\200', '\347', '\214', '\200'};
|
||||
NSString *s = [[NSString alloc] initWithBytes: bytes length: 9 encoding: NSUTF8StringEncoding];
|
||||
NSLog(@"s %@", s);
|
||||
return 0;
|
||||
}
|
||||
/* Demonstration of windows NSTask launching bug */
|
||||
|
||||
#include "Foundation/Foundation.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
NSTask *task;
|
||||
NSProcessInfo *info;
|
||||
NSDictionary *env;
|
||||
NSString *path;
|
||||
|
||||
info = [NSProcessInfo processInfo];
|
||||
env = [info environment];
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
path = @"C:\\WINDOWS\\system32\\net.exe";
|
||||
// path = @"E:\\WINNT\\system32\\net.exe";
|
||||
#else
|
||||
path = @"/bin/ls";
|
||||
#endif
|
||||
printf("Determined command to run as '%s'\n",[path lossyCString]);
|
||||
|
||||
task = [NSTask launchedTaskWithLaunchPath: path
|
||||
arguments: [NSArray array]];
|
||||
[task waitUntilExit];
|
||||
|
||||
printf("First task has completed\n");
|
||||
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
path = @"C:\\WINDOWS\\system32\\mem.exe";
|
||||
// path = @"E:\\WINNT\\system32\\mem.exe";
|
||||
#else
|
||||
path = @"/bin/ls";
|
||||
#endif
|
||||
printf("Determined command to run as '%s'\n",[path lossyCString]);
|
||||
|
||||
task = [NSTask launchedTaskWithLaunchPath: path
|
||||
arguments: [NSArray array]];
|
||||
[task waitUntilExit];
|
||||
|
||||
printf("Second task has completed\n");
|
||||
|
||||
DESTROY(arp);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue