Implement missing method

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23487 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-09-13 07:31:38 +00:00
parent e176abe621
commit 79c2ae503c
3 changed files with 61 additions and 24 deletions

View file

@ -3,6 +3,9 @@
* Source/Additions/GSMime.m: When decoding a corrupt encoded word
in a header, abandon processing of the header without appending
any decoded data.
* Headers/Foundation/NSBundle.h:
* Source/NSBundle.m:
([pathForResource:ofType:inDirectory:forLocalization:]) implement.
2006-09-10 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -322,16 +322,20 @@ GS_EXPORT NSString* const NSLoadedClasses;
- (BOOL) isLoaded;
/**
This method returns the same information as
-pathsForResourcesOfType:inDirectory: except that only non-localized
resources and resources that match the localization localizationName
are returned.
* This method returns the same information as
* -pathsForResourcesOfType:inDirectory: except that only non-localized
* resources and resources that match the localization localizationName
* are returned.<br />
* The GNUstep implementation places localised resources in the array
* before any non-localised resources.
*/
- (NSArray*) pathsForResourcesOfType: (NSString*)extension
inDirectory: (NSString*)subPath
forLocalization: (NSString*)localizationName;
/**
* Not implemented.
* This is like -pathForResource:ofType:inDirectory: but returns only
* resources matching localizationName (preferentially), or non-localized
* resources.
*/
- (NSString*) pathForResource: (NSString*)name
ofType: (NSString*)ext
@ -342,18 +346,19 @@ GS_EXPORT NSString* const NSLoadedClasses;
- (NSDictionary*) infoDictionary;
/** Returns a localized info property list based on the preferred
localization or the most appropriate localization if the preferred
one cannot be found.
*/
- (NSDictionary *)localizedInfoDictionary;
* localization or the most appropriate localization if the preferred
* one cannot be found.
*/
- (NSDictionary*) localizedInfoDictionary;
/** Returns all the localizations in the bundle. */
- (NSArray *)localizations;
- (NSArray*) localizations;
/** Returns the list of localizations that the bundle uses to search
for information. This is based on the user's preferences.
*/
- (NSArray *)preferredLocalizations;
/**
* Returns the list of localizations that the bundle uses to search
* for information. This is based on the user's preferences.
*/
- (NSArray*) preferredLocalizations;
/** Loads any executable code contained in the bundle into the
application. Load will be called implicitly if any information

View file

@ -1597,7 +1597,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
}
+ (NSArray*) _pathsForResourcesOfType: (NSString*)extension
inRootDirectory: (NSString*)bundlePath
inRootDirectory: (NSString*)bundlePath
inSubDirectory: (NSString *)subPath
{
BOOL allfiles;
@ -1657,18 +1657,21 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
inDirectory: subPath];
enumerator = [paths objectEnumerator];
while( (path = [enumerator nextObject]) )
while ((path = [enumerator nextObject]) != nil)
{
/* Add all non-localized paths, plus ones in the particular localization
(if there is one). */
NSString *theDir = [path stringByDeletingLastPathComponent];
if ([[theDir pathExtension] isEqual: @"lproj"] == NO
|| (localizationName != nil
&& [localizationName length] != 0
&& [[theDir lastPathComponent] hasPrefix: localizationName]) )
{
if ([[theDir pathExtension] isEqual: @"lproj"] == NO)
{
[result addObject: path];
}
else if ([localizationName length] > 0
&& [[theDir lastPathComponent] hasPrefix: localizationName])
{
[result insertObject: path atIndex: 0];
}
}
return result;
@ -1679,8 +1682,34 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
inDirectory: (NSString*)subPath
forLocalization: (NSString*)localizationName
{
[self notImplemented: _cmd];
return nil;
CREATE_AUTORELEASE_POOL(arp);
NSString *result = nil;
NSArray *array;
array = [self pathsForResourcesOfType: ext
inDirectory: subPath
forLocalization: localizationName];
if (array != nil)
{
NSEnumerator *enumerator = [array objectEnumerator];
NSString *path;
name = [name stringByAppendingPathExtension: ext];
while ((path = [enumerator nextObject]) != nil)
{
NSString *found = [path lastPathComponent];
if ([found isEqualToString: name] == YES)
{
result = path;
break; // localised paths occur before non-localised
}
}
}
RETAIN(result);
DESTROY(arp);
return AUTORELEASE(result);
}
+ (NSArray *) preferredLocalizationsFromArray: (NSArray *)localizationsArray
@ -1709,7 +1738,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
return [array makeImmutableCopyOnFail: NO];
}
- (NSDictionary *)localizedInfoDictionary
- (NSDictionary*) localizedInfoDictionary
{
NSString *path;
NSArray *locales;