2 Copyright (C) 2004-2005 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
22 #import <Foundation/NSObject.h>
24 @class NSUserDefaults, NSArray;
25 @class GCSFolderManager;
27 @interface Tool : NSObject
30 GCSFolderManager *folderManager;
33 + (int)runWithArgs:(NSArray *)_args;
38 #include <GDLContentStore/GCSFolder.h>
39 #include <GDLContentStore/GCSFolderManager.h>
45 if ((self = [super init])) {
46 self->ud = [[NSUserDefaults standardUserDefaults] retain];
47 self->folderManager = [[GCSFolderManager defaultFolderManager] retain];
53 [self->folderManager release];
59 - (int)runOnPath:(NSString *)_path {
61 NSString *dirname, *filename;
64 dirname = [_path stringByDeletingLastPathComponent];
65 filename = [_path lastPathComponent];
67 if ((folder = [self->folderManager folderAtPath:dirname]) == nil) {
68 [self logWithFormat:@"did not find folder for file: '%@'", dirname];
72 if ((content = [folder fetchContentWithName:filename]) == nil) {
73 [self logWithFormat:@"did not find file: '%@'", _path];
77 printf("%s\n", [content cString]);
86 [self logWithFormat:@"manager: %@", self->folderManager];
88 if (![self->folderManager canConnect]) {
89 [self logWithFormat:@"cannot connect folder-info database!"];
93 e = [[[NSProcessInfo processInfo] argumentsWithoutDefaults]
95 [e nextObject]; // skip tool name
97 while ((path = [e nextObject]))
98 [self runOnPath:path];
102 + (int)runWithArgs:(NSArray *)_args {
103 return [(Tool *)[[[self alloc] init] autorelease] run];
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 = [Tool runWithArgs:
118 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];