@@ -248,29 +248,22 @@ } - (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { - void *pool; - OFArray *pathComponents; - OFString *currentPath = nil, *component; - OFEnumerator *enumerator; + OFString *currentPath = nil; if (!createParents) { [self createDirectoryAtPath: path]; return; } if (path == nil) @throw [OFInvalidArgumentException exception]; - pool = objc_autoreleasePoolPush(); - - pathComponents = [path pathComponents]; - enumerator = [pathComponents objectEnumerator]; - while ((component = [enumerator nextObject]) != nil) { - void *pool2 = objc_autoreleasePoolPush(); + for (OFString *component in [path pathComponents]) { + void *pool = objc_autoreleasePoolPush(); if (currentPath != nil) currentPath = [currentPath stringByAppendingPathComponent: component]; else @@ -280,16 +273,14 @@ ![self directoryExistsAtPath: currentPath]) [self createDirectoryAtPath: currentPath]; [currentPath retain]; - objc_autoreleasePoolPop(pool2); + objc_autoreleasePoolPop(pool); [currentPath autorelease]; } - - objc_autoreleasePoolPop(pool); } - (OFArray*)contentsOfDirectoryAtPath: (OFString*)path { OFMutableArray *files; @@ -593,12 +584,10 @@ destinationPath: destination errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; - OFEnumerator *enumerator; - OFString *item; @try { [self createDirectoryAtPath: destination]; #ifdef OF_HAVE_CHMOD [self changePermissionsOfItemAtPath: destination @@ -620,12 +609,11 @@ errNo: [e errNo]]; @throw e; } - enumerator = [contents objectEnumerator]; - while ((item = [enumerator nextObject]) != nil) { + for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; sourcePath = [source stringByAppendingPathComponent: item]; @@ -790,12 +778,10 @@ @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; - OFEnumerator *enumerator; - OFString *item; @try { contents = [self contentsOfDirectoryAtPath: path]; } @catch (id e) { /* @@ -811,12 +797,11 @@ errNo: [e errNo]]; @throw e; } - enumerator = [contents objectEnumerator]; - while ((item = [enumerator nextObject]) != nil) { + for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); [self removeItemAtPath: [path stringByAppendingPathComponent: item]];