From: helge Date: Mon, 6 Sep 2004 16:13:33 +0000 (+0000) Subject: added a new mkdirs like method to NSFileManager X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1748510030ddf2ca27ba42e1c74223a5973ee84;p=sope added a new mkdirs like method to NSFileManager git-svn-id: http://svn.opengroupware.org/SOPE/trunk@112 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/NGExtensions/ChangeLog b/sope-core/NGExtensions/ChangeLog index da7dd14b..78c06dd1 100644 --- a/sope-core/NGExtensions/ChangeLog +++ b/sope-core/NGExtensions/ChangeLog @@ -1,10 +1,14 @@ 2004-09-06 Helge Hess - + + * 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 * v4.3.112 diff --git a/sope-core/NGExtensions/FdExt.subproj/NSFileManager+Extensions.m b/sope-core/NGExtensions/FdExt.subproj/NSFileManager+Extensions.m index 0e1e5e7f..5815f053 100644 --- a/sope-core/NGExtensions/FdExt.subproj/NSFileManager+Extensions.m +++ b/sope-core/NGExtensions/FdExt.subproj/NSFileManager+Extensions.m @@ -1,7 +1,7 @@ /* - 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 @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "NSFileManager+Extensions.h" #include "NGFileFolderInfoDataSource.h" @@ -37,6 +36,43 @@ @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 { @@ -102,8 +138,8 @@ /* datasources (work on folders) */ - (EODataSource *)dataSourceAtPath:(NSString *)_path { - return - [[[NGFileFolderInfoDataSource alloc] initWithFolderPath:_path] autorelease]; + return [[[NGFileFolderInfoDataSource alloc] initWithFolderPath:_path] + autorelease]; } - (EODataSource *)dataSource { diff --git a/sope-core/NGExtensions/NGExtensions/NSFileManager+Extensions.h b/sope-core/NGExtensions/NGExtensions/NSFileManager+Extensions.h index 6743cb60..af4e48d8 100644 --- a/sope-core/NGExtensions/NGExtensions/NSFileManager+Extensions.h +++ b/sope-core/NGExtensions/NGExtensions/NSFileManager+Extensions.h @@ -1,7 +1,7 @@ /* - 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 @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __NSFileManager_Extensions_H__ #define __NSFileManager_Extensions_H__ @@ -27,6 +26,9 @@ #include @interface NSFileManager(ExtendedFileManager) < NGFileManagerDataSources > + +- (BOOL)createDirectoriesAtPath:(NSString *)_p attributes:(NSDictionary *)_a; + @end #endif /* __NSFileManager_Extensions_H__ */ diff --git a/sope-core/NGExtensions/Version b/sope-core/NGExtensions/Version index c2c9a8e5..596f871c 100644 --- a/sope-core/NGExtensions/Version +++ b/sope-core/NGExtensions/Version @@ -1,5 +1,5 @@ # version -SUBMINOR_VERSION:=113 +SUBMINOR_VERSION:=114 # v4.2.72 requires libEOControl v4.2.39