@@ -316,10 +316,31 @@ [ret makeImmutable]; return ret; } } + +- (OFString *)stringByAppendingPathExtension: (OFString *)extension +{ + if ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"]) { + void *pool = objc_autoreleasePoolPush(); + OFMutableArray *components; + OFString *fileName, *ret; + + components = + [[self.pathComponents mutableCopy] autorelease]; + fileName = [components.lastObject + stringByAppendingFormat: @".%@", extension]; + [components replaceObjectAtIndex: components.count - 1 + withObject: fileName]; + + ret = [[OFString pathWithComponents: components] retain]; + objc_autoreleasePoolPop(pool); + return [ret autorelease]; + } else + return [self stringByAppendingFormat: @".%@", extension]; +} - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]);