mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-21 12:41:19 +00:00
Added +bundleForLibrary: and +bundleForTool:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11874 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9069bb7a7a
commit
df720d5aed
1 changed files with 78 additions and 0 deletions
|
@ -1318,6 +1318,84 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
||||||
within the GNUstep directory structure specified by the environment
|
within the GNUstep directory structure specified by the environment
|
||||||
variables. */
|
variables. */
|
||||||
|
|
||||||
|
/* Return a bundle which accesses the first existing directory from the list
|
||||||
|
GNUSTEP_USER_ROOT/Libraries/Resources/libraryName/
|
||||||
|
GNUSTEP_NETWORK_ROOT/Libraries/Resources/libraryName/
|
||||||
|
GNUSTEP_LOCAL_ROOT/Libraries/Resources/libraryName/
|
||||||
|
GNUSTEP_SYSTEM_ROOT/Libraries/Resources/libraryName/
|
||||||
|
*/
|
||||||
|
+ (NSBundle *) bundleForLibrary: (NSString *)libraryName
|
||||||
|
{
|
||||||
|
NSArray *paths;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *path;
|
||||||
|
NSString *tail;
|
||||||
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
|
|
||||||
|
if (libraryName == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = [@"Resources" stringByAppendingPathComponent: libraryName];
|
||||||
|
|
||||||
|
paths = NSSearchPathForDirectoriesInDomains (GSLibrariesDirectory,
|
||||||
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
|
enumerator = [paths objectEnumerator];
|
||||||
|
while ((path = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
BOOL isDir;
|
||||||
|
path = [path stringByAppendingPathComponent: tail];
|
||||||
|
|
||||||
|
if ([fm fileExistsAtPath: path isDirectory: &isDir] && isDir)
|
||||||
|
{
|
||||||
|
return [NSBundle bundleWithPath: path];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a bundle which accesses the first existing directory from the list
|
||||||
|
GNUSTEP_USER_ROOT/Tools/Resources/libraryName/
|
||||||
|
GNUSTEP_NETWORK_ROOT/Tools/Resources/libraryName/
|
||||||
|
GNUSTEP_LOCAL_ROOT/Tools/Resources/libraryName/
|
||||||
|
GNUSTEP_SYSTEM_ROOT/Tools/Resources/libraryName/
|
||||||
|
*/
|
||||||
|
+ (NSBundle *) bundleForTool: (NSString *)toolName
|
||||||
|
{
|
||||||
|
NSArray *paths;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *path;
|
||||||
|
NSString *tail;
|
||||||
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
|
|
||||||
|
if (toolName == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = [@"Resources" stringByAppendingPathComponent: toolName];
|
||||||
|
|
||||||
|
paths = NSSearchPathForDirectoriesInDomains (GSLibrariesDirectory,
|
||||||
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
|
enumerator = [paths objectEnumerator];
|
||||||
|
while ((path = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
BOOL isDir;
|
||||||
|
path = [path stringByAppendingPathComponent: tail];
|
||||||
|
|
||||||
|
if ([fm fileExistsAtPath: path isDirectory: &isDir] && isDir)
|
||||||
|
{
|
||||||
|
return [NSBundle bundleWithPath: path];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSString *) _absolutePathOfExecutable: (NSString *)path
|
+ (NSString *) _absolutePathOfExecutable: (NSString *)path
|
||||||
{
|
{
|
||||||
NSFileManager *mgr;
|
NSFileManager *mgr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue