@@ -246,10 +246,47 @@ #endif @throw [OFCreateDirectoryFailedException exceptionWithClass: self path: path]; } + ++ (void)createDirectoryAtPath: (OFString*)path + createParents: (BOOL)createParents +{ + OFAutoreleasePool *pool, *pool2; + OFArray *pathComponents; + OFString *currentPath = nil, *component; + OFEnumerator *enumerator; + + if (!createParents) { + [OFFile createDirectoryAtPath: path]; + return; + } + + pool = [[OFAutoreleasePool alloc] init]; + + pathComponents = [path pathComponents]; + enumerator = [pathComponents objectEnumerator]; + pool2 = [[OFAutoreleasePool alloc] init]; + while ((component = [enumerator nextObject]) != nil) { + if (currentPath != nil) + currentPath = [OFString + stringWithPath: currentPath, component, nil]; + else + currentPath = component; + + if (![currentPath isEqual: @""] && + ![OFFile directoryExistsAtPath: currentPath]) + [OFFile createDirectoryAtPath: currentPath]; + + [currentPath retain]; + [pool2 releaseObjects]; + [currentPath autorelease]; + } + + [pool release]; +} + (OFArray*)filesInDirectoryAtPath: (OFString*)path { OFAutoreleasePool *pool; OFMutableArray *files = [OFMutableArray array];