Ensure that NSBundle is initialised before changing current directory.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22522 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-02-21 07:51:17 +00:00
parent be45c12fd5
commit f6aad79d90
3 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2006-02-21 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: Ensure that NSBundle is initialised before
changing the current directory.
2006-02-20 Richard Frith-Macdonald <rfm@gnu.org>
* NSTimeZones/NSTimeZones.tar: regenerated.

View file

@ -59,7 +59,7 @@ GNUstepConfig(NSDictionary *newConfig);
* Returns the location of the defaults database for the specified user.
*/
GS_EXPORT NSString*
GSDefaultRootForUser(NSString *username);
GSDefaultsRootForUser(NSString *username);
/**
* The config dictiuonary passed to this function should be a

View file

@ -48,6 +48,7 @@
#include "Foundation/NSProcessInfo.h"
#include "Foundation/NSEnumerator.h"
#include "Foundation/NSSet.h"
#include "Foundation/NSBundle.h"
#include "GSPrivate.h"
#include <string.h>
@ -352,7 +353,19 @@ static NSStringEncoding defaultEncoding;
*/
- (BOOL) changeCurrentDirectoryPath: (NSString*)path
{
static Class bundleClass = 0;
const _CHAR *lpath = [self fileSystemRepresentationWithPath: path];
/*
* On some systems the only way NSBundle can determine the path to the
* executable is by searching for it ... so it needs to know what was
* the current directory at launch time ... so we must make sure it is
* initialised before we change the current directory.
*/
if (bundleClass == 0)
{
bundleClass = [NSBundle class];
}
#if defined(__MINGW32__)
return SetCurrentDirectoryW(lpath) == TRUE ? YES : NO;
#else