2004-09-06 Helge Hess <helge.hess@skyrix.com>
-
+
+ * FdExt.subproj/NSFileManager+Extensions.m: added new method:
+ -createDirectoriesAtPath:attributes: (comparable to mkdirs)
+ (v4.3.114)
+
* NGBundleManager.m: changed bundle resource lookup to check loaded
bundles before scanning the NGBundlePath resources (is faster and
fixes an issue with a bundle loaded but not in the search path)
(v4.3.113)
-
+
2004-09-05 Helge Hess <helge.hess@opengroupware.org>
* v4.3.112
/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "NSFileManager+Extensions.h"
#include "NGFileFolderInfoDataSource.h"
@implementation NSFileManager(ExtendedFileManagerImp)
+/* directories */
+
+- (BOOL)createDirectoriesAtPath:(NSString *)_p attributes:(NSDictionary *)_a {
+ unsigned i, count;
+ NSArray *pc;
+ BOOL isDir;
+
+ if ([_p length] == 0)
+ return NO;
+ if ([self fileExistsAtPath:_p isDirectory:&isDir])
+ return isDir;
+
+ pc = [_p pathComponents];
+ if ((count = [pc count]) == 0)
+ return YES;
+
+ for (i = 0; i < count; i++) {
+ NSString *fp;
+ NSRange r;
+
+ r.location = 0;
+ r.length = i + 1;
+
+ fp = [NSString pathWithComponents:[pc subarrayWithRange:r]];
+ if ([self fileExistsAtPath:fp isDirectory:&isDir]) {
+ if (!isDir) /* exists, but is a file */
+ return NO;
+ continue;
+ }
+
+ if (![self createDirectoryAtPath:fp attributes:_a])
+ /* failed to create */
+ return NO;
+ }
+ return YES;
+}
+
/* path modifications */
- (NSString *)standardizePath:(NSString *)_path {
/* datasources (work on folders) */
- (EODataSource *)dataSourceAtPath:(NSString *)_path {
- return
- [[[NGFileFolderInfoDataSource alloc] initWithFolderPath:_path] autorelease];
+ return [[[NGFileFolderInfoDataSource alloc] initWithFolderPath:_path]
+ autorelease];
}
- (EODataSource *)dataSource {
/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __NSFileManager_Extensions_H__
#define __NSFileManager_Extensions_H__
#include <NGExtensions/NGFileManager.h>
@interface NSFileManager(ExtendedFileManager) < NGFileManagerDataSources >
+
+- (BOOL)createDirectoriesAtPath:(NSString *)_p attributes:(NSDictionary *)_a;
+
@end
#endif /* __NSFileManager_Extensions_H__ */