Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -75,10 +75,12 @@ OFXMLElement+Serialization.m \ OFXMLElementBuilder.m \ OFXMLNode.m \ OFXMLParser.m \ OFXMLProcessingInstructions.m \ + OFZIPArchive.m \ + OFZIPArchiveEntry.m \ base64.m \ crc32.m \ of_asprintf.m \ of_strptime.m \ unicode.m \ @@ -88,13 +90,11 @@ ${USE_SRCS_THREADS} SRCS_FILES = OFFile.m \ OFFileManager.m \ OFINICategory.m \ OFINIFile.m \ - OFSettings.m \ - OFZIPArchive.m \ - OFZIPArchiveEntry.m + OFSettings.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFHTTPClient.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -58,17 +58,19 @@ * @param stream A seekable stream from which the ZIP archive will be read * @return A new, autoreleased OFZIPArchive */ + (instancetype)archiveWithSeekableStream: (OFSeekableStream*)stream; +#ifdef OF_HAVE_FILES /*! * @brief Creates a new OFZIPArchive object with the specified file. * * @param path The path to the ZIP file * @return A new, autoreleased OFZIPArchive */ + (instancetype)archiveWithPath: (OFString*)path; +#endif /*! * @brief Initializes an already allocated OFZIPArchive object with the * specified seekable stream. * @@ -75,18 +77,20 @@ * @param stream A seekable stream from which the ZIP archive will be read * @return An initialized OFZIPArchive */ - initWithSeekableStream: (OFSeekableStream*)stream; +#ifdef OF_HAVE_FILES /*! * @brief Initializes an already allocated OFZIPArchive object with the * specified file. * * @param path The path to the ZIP file * @return An initialized OFZIPArchive */ - initWithPath: (OFString*)path; +#endif /*! * @brief Returns the entries of the central directory of the archive as an * array of objects of class @ref OFZIPArchiveEntry. * Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -22,11 +22,14 @@ #import "OFZIPArchiveEntry.h" #import "OFZIPArchiveEntry+Private.h" #import "OFDataArray.h" #import "OFArray.h" #import "OFDictionary.h" -#import "OFFile.h" +#import "OFSeekableStream.h" +#ifdef OF_HAVE_FILES +# import "OFFile.h" +#endif #import "OFInflateStream.h" #import "OFInflate64Stream.h" #import "crc32.h" @@ -42,11 +45,10 @@ /* * FIXME: Current limitations: * - Split archives are not supported. * - Write support is missing. - * - The ZIP has to be a file on the local file system. * - Encrypted files cannot be read. */ @interface OFZIPArchive () - (void)OF_readZIPInfo; @@ -137,14 +139,16 @@ + (instancetype)archiveWithSeekableStream: (OFSeekableStream*)stream { return [[[self alloc] initWithSeekableStream: stream] autorelease]; } +#ifdef OF_HAVE_FILES + (instancetype)archiveWithPath: (OFString*)path { return [[[self alloc] initWithPath: path] autorelease]; } +#endif - init { OF_INVALID_INIT_METHOD } @@ -164,10 +168,11 @@ } return self; } +#ifdef OF_HAVE_FILES - initWithPath: (OFString*)path { self = [super init]; @try { @@ -181,10 +186,11 @@ @throw e; } return self; } +#endif - (void)dealloc { [_stream release]; [_archiveComment release]; Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -18,12 +18,12 @@ #import "OFZIPArchiveEntry.h" #import "OFZIPArchiveEntry+Private.h" #import "OFString.h" #import "OFDataArray.h" -#import "OFFile.h" #import "OFDate.h" +#import "OFStream.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" extern uint32_t of_zip_archive_read_field32(uint8_t**, uint16_t*);