2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include <EOControl/EOControl.h>
25 #include <NGExtensions/NSFileManager+Extensions.h>
26 #include <NGExtensions/NGFileFolderInfoDataSource.h>
27 #include <NGExtensions/NGExtensions.h>
29 @interface BMLookupTool : NSObject
34 - (int)runWithArguments:(NSArray *)_args;
38 @implementation BMLookupTool
41 if ((self = [super init])) {
42 self->bm = [[NGBundleManager defaultBundleManager] retain];
51 - (void)listResourcesOfType:(NSString *)btype {
52 NSEnumerator *resources;
55 printf("lookup resources of type: '%s'\n", [btype cString]);
57 resources = [[bm providedResourcesOfType:btype] objectEnumerator];
58 while ((resource = [resources nextObject])) {
61 if ((rname = [resource objectForKey:@"name"]) != nil) {
64 bundle = [bm bundleProvidingResource:rname ofType:btype];
65 printf(" resource '%s'\n", [rname cString]);
66 printf(" bundle: '%s'\n", [[bundle bundlePath] cString]);
67 printf(" info: %s\n", [[resource description] cString]);
70 printf(" resource info: %s\n", [[resource description] cString]);
74 - (void)lookupResourceWithName:(NSString *)bname ofType:(NSString *)btype {
77 printf("lookup resource '%s' of type: '%s'\n",
78 [bname cString], [btype cString]);
80 bundle = [self->bm bundleProvidingResource:bname ofType:btype];
81 printf(" bundle: '%s'\n", [[bundle bundlePath] cString]);
83 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"load"]) {
85 NSLog(@"Could not load bundle: %@", bundle);
87 printf(" did load bundle: %s\n", [[bundle description] cString]);
91 - (int)runWithArguments:(NSArray *)_args {
92 if ([_args count] < 2) {
93 NSLog(@"usage: %@ type name", [[_args objectAtIndex:0] lastPathComponent]);
97 if ([_args count] == 2) {
98 [self listResourcesOfType:[_args objectAtIndex:1]];
102 [self lookupResourceWithName:[_args objectAtIndex:2]
103 ofType:[_args objectAtIndex:1]];
107 @end /* BMLookupTool */
109 int main(int argc, char **argv, char **env) {
110 NSAutoreleasePool *pool;
113 pool = [[NSAutoreleasePool alloc] init];
114 #if LIB_FOUNDATION_LIBRARY
115 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
118 rc = [[[[BMLookupTool alloc] init] autorelease]
120 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];