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:
rfm 2008-03-05 09:32:49 +00:00
parent cadb5df03b
commit ddf52b8752
3 changed files with 85 additions and 9 deletions

View file

@ -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
}
/*