Oolite
Loading...
Searching...
No Matches
NSBundle(Override) Category Reference

#include <NSBundle+Override.h>

Instance Methods

(NSDictionary *) - infoDictionary

Detailed Description

Definition at line 3 of file NSBundle+Override.h.

Method Documentation

◆ infoDictionary

- (NSDictionary *) infoDictionary

Overrides the standard -infoDictionary method via a category name-clash. Forces the bundle to manually load and return the contents of 'info-gnustep.plist'.

Definition at line 20 of file NSBundle+Override.m.

21{
22 NSFileManager* fileManager = [NSFileManager defaultManager];
23 NSString* startingDir = [fileManager currentDirectoryPath]; // Start from cwd
24
25 NSString* primaryResourcesPath = [startingDir stringByAppendingPathComponent:@"Resources"];
26 BOOL isDir = NO;
27
28 NSString* resourcesFolder = nil;
29 if ([fileManager fileExistsAtPath:primaryResourcesPath isDirectory:&isDir] && isDir) {
30 resourcesFolder = primaryResourcesPath;
31 } else {
32 // Fallback: Look in startingDir / ../share/oolite/Resources (Standard Linux system layout)
33 NSString* fallbackPath = [[startingDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"share/oolite/Resources"];
34 resourcesFolder = [fallbackPath stringByStandardizingPath];
35 }
36
37 // Append the target file name to the resolved path root
38 NSString* plistPath = [resourcesFolder stringByAppendingPathComponent:@"Info-gnustep.plist"];
39
40 // Load the target configuration file
41 NSDictionary* gnustepPlist = [NSDictionary dictionaryWithContentsOfFile:plistPath];
42 NSMutableDictionary* workingDict = nil;
43
44 if (gnustepPlist) {
45 workingDict = [gnustepPlist mutableCopy];
46 } else {
47 // Fallback block prevents runtime crashes if files are missing during dev/build refactors
48 workingDict = [[NSMutableDictionary alloc] init];
49 NSLog(@"[Oolite-Core] Warning: Failed to find info-gnustep.plist at calculated path: %@", plistPath);
50 }
51
52 // Return the dictionary cleanly managed for memory
53 return [workingDict autorelease];
54}
#define NSLog(format,...)
Definition OOLogging.h:148
return nil

References infoDictionary, nil, and NSLog.

Referenced by infoDictionary.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following files: