From 4a4a8020606f652652d4de2acfc2afd267a4e153 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 8 Dec 2024 13:40:59 +0000 Subject: [PATCH] Set launch directory before AbsolutePathOfExecutable() needs it. --- Source/NSBundle.m | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 56ba03551..1762a8e3e 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -55,14 +55,18 @@ #import "GSPrivate.h" +/* Store the working directory at startup */ +static NSString *_launchDirectory = nil; + static NSFileManager * manager() { static NSFileManager *mgr = nil; - if (mgr == nil) + if (nil == mgr) { mgr = RETAIN([NSFileManager defaultManager]); + ASSIGN(_launchDirectory, [mgr currentDirectoryPath]); [[NSObject leakAt: &mgr] release]; } return mgr; @@ -186,9 +190,6 @@ + (NSString**) frameworkClasses; static NSMapTable *_byClass = NULL; static NSMapTable *_byIdentifier = NULL; -/* Store the working directory at startup */ -static NSString *_launchDirectory = nil; - static NSString *_base_version = OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION); @@ -1719,8 +1720,6 @@ + (void) initialize if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil) library_combo = RETAIN(str); - _launchDirectory = RETAIN([manager() currentDirectoryPath]); - _gnustep_bundle = RETAIN([self bundleForLibrary: @"gnustep-base" version: _base_version]);