Index: src/OFArchiveIRIHandler.m ================================================================== --- src/OFArchiveIRIHandler.m +++ src/OFArchiveIRIHandler.m @@ -73,12 +73,12 @@ * archive. */ if ([scheme isEqual: @"gzip"]) { stream = [OFIRIHandler openItemAtIRI: [OFIRI IRIWithString: IRI.path] - mode: @"r"]; - stream = [OFGZIPStream streamWithStream: stream mode: @"r"]; + mode: mode]; + stream = [OFGZIPStream streamWithStream: stream mode: mode]; goto end; } percentEncodedPath = IRI.percentEncodedPath; pos = [percentEncodedPath rangeOfString: @"!"].location; @@ -93,11 +93,11 @@ OFMakeRange(pos + 1, percentEncodedPath.length - pos - 1)] .stringByRemovingPercentEncoding; if ([scheme isEqual: @"lha-archive"]) { OFLHAArchive *archive = [OFLHAArchive archiveWithIRI: archiveIRI - mode: @"r"]; + mode: mode]; OFLHAArchiveEntry *entry; while ((entry = [archive nextEntry]) != nil) { if ([entry.fileName isEqual: path]) { stream = [archive streamForReadingCurrentEntry]; @@ -108,11 +108,11 @@ @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: mode errNo: ENOENT]; } else if ([scheme isEqual: @"tar-archive"]) { OFTarArchive *archive = [OFTarArchive archiveWithIRI: archiveIRI - mode: @"r"]; + mode: mode]; OFTarArchiveEntry *entry; while ((entry = [archive nextEntry]) != nil) { if ([entry.fileName isEqual: path]) { stream = [archive streamForReadingCurrentEntry]; @@ -123,16 +123,16 @@ @throw [OFOpenItemFailedException exceptionWithIRI: IRI mode: mode errNo: ENOENT]; } else if ([scheme isEqual: @"zip-archive"]) { OFZIPArchive *archive = [OFZIPArchive archiveWithIRI: archiveIRI - mode: @"r"]; + mode: mode]; stream = [archive streamForReadingFile: path]; } else if ([scheme isEqual: @"zoo-archive"]) { OFZooArchive *archive = [OFZooArchive archiveWithIRI: archiveIRI - mode: @"r"]; + mode: mode]; OFZooArchiveEntry *entry; while ((entry = [archive nextEntry]) != nil) { if ([entry.fileName isEqual: path]) { stream = [archive streamForReadingCurrentEntry]; Index: src/OFFileIRIHandler.m ================================================================== --- src/OFFileIRIHandler.m +++ src/OFFileIRIHandler.m @@ -677,13 +677,23 @@ } - (OFStream *)openItemAtIRI: (OFIRI *)IRI mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); - OFFile *file = [[OFFile alloc] - initWithPath: IRI.fileSystemRepresentation - mode: mode]; + OFFile *file; + + @try { + file = [OFFile fileWithPath: IRI.fileSystemRepresentation + mode: mode]; + } @catch (OFOpenItemFailedException *e) { + /* The thrown one has a path instead of an IRI set. */ + @throw [OFOpenItemFailedException exceptionWithIRI: IRI + mode: mode + errNo: e.errNo]; + } + + [file retain]; objc_autoreleasePoolPop(pool); return [file autorelease]; }