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 type:(NSString *)_type {
62 [self logWithFormat:@"mkdir %@ at path: '%@'", _type, _path];
64 if ([self->folderManager folderExistsAtPath:_path]) {
65 [self logWithFormat:@"folder already exist at path: '%@'", _path];
69 if ((error = [self->folderManager createFolderOfType:_type atPath:_path])) {
70 [self logWithFormat:@"creation of folder %@ at %@ failed: %@",
75 if ([self->folderManager folderExistsAtPath:_path])
76 [self logWithFormat:@"CREATED."];
78 [self logWithFormat:@"cannot find fresh folder?"];
88 [self logWithFormat:@"manager: %@", self->folderManager];
90 if (![self->folderManager canConnect]) {
91 [self logWithFormat:@"cannot connect folder-info database!"];
95 e = [[[NSProcessInfo processInfo] argumentsWithoutDefaults]
97 [e nextObject]; // skip tool name
99 type = [[[e nextObject] copy] autorelease];
101 while ((path = [e nextObject]))
102 [self runOnPath:path type:type];
106 + (int)runWithArgs:(NSArray *)_args {
107 return [(Tool *)[[[self alloc] init] autorelease] run];
112 int main(int argc, char **argv, char **env) {
113 NSAutoreleasePool *pool;
116 pool = [[NSAutoreleasePool alloc] init];
117 #if LIB_FOUNDATION_LIBRARY
118 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
121 rc = [Tool runWithArgs:
122 [[NSProcessInfo processInfo] argumentsWithoutDefaults]];