2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <EOControl/EOControl.h>
24 #include <NGExtensions/NSFileManager+Extensions.h>
25 #include <NGExtensions/NGFileFolderInfoDataSource.h>
26 #include <NGExtensions/NGExtensions.h>
28 @interface BMLookupTool : NSObject
33 - (int)runWithArguments:(NSArray *)_args;
37 @implementation BMLookupTool
40 if ((self = [super init])) {
41 self->bm = [[NGBundleManager defaultBundleManager] retain];
50 - (void)listResourcesOfType:(NSString *)btype {
51 NSEnumerator *resources;
54 printf("lookup resources of type: '%s'\n", [btype cString]);
56 resources = [[bm providedResourcesOfType:btype] objectEnumerator];
57 while ((resource = [resources nextObject])) {
60 if ((rname = [resource objectForKey:@"name"]) != nil) {
63 bundle = [bm bundleProvidingResource:rname ofType:btype];
64 printf(" resource '%s'\n", [rname cString]);
65 printf(" bundle: '%s'\n", [[bundle bundlePath] cString]);
66 printf(" info: %s\n", [[resource description] cString]);
69 printf(" resource info: %s\n", [[resource description] cString]);
73 - (void)lookupResourceWithName:(NSString *)bname ofType:(NSString *)btype {
76 printf("lookup resource '%s' of type: '%s'\n",
77 [bname cString], [btype cString]);
79 bundle = [self->bm bundleProvidingResource:bname ofType:btype];
80 printf(" bundle: '%s'\n", [[bundle bundlePath] cString]);
82 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"load"]) {
84 NSLog(@"Could not load bundle: %@", bundle);
86 printf(" did load bundle: %s\n", [[bundle description] cString]);
90 - (int)runWithArguments:(NSArray *)_args {
91 if ([_args count] < 2) {
92 NSLog(@"usage: %@ type name", [[_args objectAtIndex:0] lastPathComponent]);
96 if ([_args count] == 2) {
97 [self listResourcesOfType:[_args objectAtIndex:1]];
101 [self lookupResourceWithName:[_args objectAtIndex:2]
102 ofType:[_args objectAtIndex:1]];
106 @end /* BMLookupTool */
108 int main(int argc, char **argv, char **env) {
109 NSAutoreleasePool *pool;
112 pool = [[NSAutoreleasePool alloc] init];
113 #if LIB_FOUNDATION_LIBRARY
114 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
117 rc = [[[[BMLookupTool alloc] init] autorelease]
119 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];