ObjFW  Check-in [1c78b3a4db]

Overview
Comment:OFZIPArchive: Initial implementation.

Still a lot to do, see list of FIXMEs in the source.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c78b3a4db12d837ec3bf7bc16e2fa38d058f0d4824828e09d02381d93c67a61
User & Date: js on 2013-08-12 21:59:05
Other Links: manifest | tags
Context
2013-08-13
10:39
Add a few more instancetypes. check-in: 73ae6fa60f user: js tags: trunk
2013-08-12
21:59
OFZIPArchive: Initial implementation. check-in: 1c78b3a4db user: js tags: trunk
13:26
Fix OFSeekableStream. check-in: d101b6f8b4 user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [ded6ae00ad] to [46a4859faa].

360
361
362
363
364
365
366




367
368
369
370
371
372
373
		4BCAA9B01772432F003EF859 /* OFMessagePackExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BCAA9AE1772432E003EF859 /* OFMessagePackExtension.m */; };
		4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */; settings = {ATTRIBUTES = (); }; };
		4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; };
		4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */; };
		4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; };




		4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */; };
		4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; };
		4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; };
		4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; };
		4BF33AFE133807A20059CEF7 /* OFDataArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66F1235358D0076B512 /* OFDataArrayTests.m */; };
		4BF33AFF133807A20059CEF7 /* OFDateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E512DF4259005C7A0C /* OFDateTests.m */; };
		4BF33B00133807A20059CEF7 /* OFDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF6701235358D0076B512 /* OFDictionaryTests.m */; };







>
>
>
>







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
		4BCAA9B01772432F003EF859 /* OFMessagePackExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BCAA9AE1772432E003EF859 /* OFMessagePackExtension.m */; };
		4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */; settings = {ATTRIBUTES = (); }; };
		4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; };
		4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */; };
		4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; };
		4BE52D2117B990B4005958D1 /* OFZIPArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE52D1F17B990B4005958D1 /* OFZIPArchive.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BE52D2217B990B4005958D1 /* OFZIPArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE52D2017B990B4005958D1 /* OFZIPArchive.m */; };
		4BE52D2517B990DA005958D1 /* OFChecksumFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BE52D2317B990DA005958D1 /* OFChecksumFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BE52D2617B990DA005958D1 /* OFChecksumFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE52D2417B990DA005958D1 /* OFChecksumFailedException.m */; };
		4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */; };
		4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; };
		4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; };
		4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; };
		4BF33AFE133807A20059CEF7 /* OFDataArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66F1235358D0076B512 /* OFDataArrayTests.m */; };
		4BF33AFF133807A20059CEF7 /* OFDateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E512DF4259005C7A0C /* OFDateTests.m */; };
		4BF33B00133807A20059CEF7 /* OFDictionaryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF6701235358D0076B512 /* OFDictionaryTests.m */; };
796
797
798
799
800
801
802




803
804
805
806
807
808
809
		4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; };
		4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; };
		4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; };
		4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; };
		4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; };
		4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+Hashing.h"; path = "src/OFDataArray+Hashing.h"; sourceTree = SOURCE_ROOT; };
		4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+Hashing.m"; path = "src/OFDataArray+Hashing.m"; sourceTree = SOURCE_ROOT; };




		4BE5F0D712DF4225005C7A0C /* OFConstantString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConstantString.h; path = src/OFConstantString.h; sourceTree = SOURCE_ROOT; };
		4BE5F0D812DF4225005C7A0C /* OFConstantString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConstantString.m; path = src/OFConstantString.m; sourceTree = SOURCE_ROOT; };
		4BE5F0D912DF4225005C7A0C /* OFDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFDate.h; path = src/OFDate.h; sourceTree = SOURCE_ROOT; };
		4BE5F0DA12DF4225005C7A0C /* OFDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDate.m; path = src/OFDate.m; sourceTree = SOURCE_ROOT; };
		4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlockTests.m; path = tests/OFBlockTests.m; sourceTree = SOURCE_ROOT; };
		4BE5F0E512DF4259005C7A0C /* OFDateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDateTests.m; path = tests/OFDateTests.m; sourceTree = SOURCE_ROOT; };
		4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = forwarding.S; path = src/forwarding.S; sourceTree = "<group>"; };







>
>
>
>







800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
		4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; };
		4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; };
		4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; };
		4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; };
		4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; };
		4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+Hashing.h"; path = "src/OFDataArray+Hashing.h"; sourceTree = SOURCE_ROOT; };
		4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+Hashing.m"; path = "src/OFDataArray+Hashing.m"; sourceTree = SOURCE_ROOT; };
		4BE52D1F17B990B4005958D1 /* OFZIPArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFZIPArchive.h; path = src/OFZIPArchive.h; sourceTree = "<group>"; };
		4BE52D2017B990B4005958D1 /* OFZIPArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFZIPArchive.m; path = src/OFZIPArchive.m; sourceTree = "<group>"; };
		4BE52D2317B990DA005958D1 /* OFChecksumFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFChecksumFailedException.h; path = src/exceptions/OFChecksumFailedException.h; sourceTree = "<group>"; };
		4BE52D2417B990DA005958D1 /* OFChecksumFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFChecksumFailedException.m; path = src/exceptions/OFChecksumFailedException.m; sourceTree = "<group>"; };
		4BE5F0D712DF4225005C7A0C /* OFConstantString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConstantString.h; path = src/OFConstantString.h; sourceTree = SOURCE_ROOT; };
		4BE5F0D812DF4225005C7A0C /* OFConstantString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConstantString.m; path = src/OFConstantString.m; sourceTree = SOURCE_ROOT; };
		4BE5F0D912DF4225005C7A0C /* OFDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFDate.h; path = src/OFDate.h; sourceTree = SOURCE_ROOT; };
		4BE5F0DA12DF4225005C7A0C /* OFDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDate.m; path = src/OFDate.m; sourceTree = SOURCE_ROOT; };
		4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlockTests.m; path = tests/OFBlockTests.m; sourceTree = SOURCE_ROOT; };
		4BE5F0E512DF4259005C7A0C /* OFDateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFDateTests.m; path = tests/OFDateTests.m; sourceTree = SOURCE_ROOT; };
		4BEF2D3017A5BF5200BB8BA3 /* forwarding.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = forwarding.S; path = src/forwarding.S; sourceTree = "<group>"; };
897
898
899
900
901
902
903


904
905
906
907
908
909
910
				4B90B799133AD87D00BD33CB /* OFBindFailedException.m */,
				4B067FAF177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.h */,
				4B067FB0177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.m */,
				4B067FB1177BA6F900B8CFDA /* OFChangeOwnerFailedException.h */,
				4B067FB2177BA6F900B8CFDA /* OFChangeOwnerFailedException.m */,
				4B067FB3177BA6F900B8CFDA /* OFChangePermissionsFailedException.h */,
				4B067FB4177BA6F900B8CFDA /* OFChangePermissionsFailedException.m */,


				4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */,
				4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */,
				4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */,
				4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */,
				4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */,
				4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */,
				4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */,







>
>







905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
				4B90B799133AD87D00BD33CB /* OFBindFailedException.m */,
				4B067FAF177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.h */,
				4B067FB0177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.m */,
				4B067FB1177BA6F900B8CFDA /* OFChangeOwnerFailedException.h */,
				4B067FB2177BA6F900B8CFDA /* OFChangeOwnerFailedException.m */,
				4B067FB3177BA6F900B8CFDA /* OFChangePermissionsFailedException.h */,
				4B067FB4177BA6F900B8CFDA /* OFChangePermissionsFailedException.m */,
				4BE52D2317B990DA005958D1 /* OFChecksumFailedException.h */,
				4BE52D2417B990DA005958D1 /* OFChecksumFailedException.m */,
				4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */,
				4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */,
				4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */,
				4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */,
				4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */,
				4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */,
				4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */,
1240
1241
1242
1243
1244
1245
1246


1247
1248
1249
1250
1251
1252
1253
				4B0D249511DFAA3D00ED6FFC /* OFXMLElementBuilder.m */,
				4B11005A14329B9A003A45D8 /* OFXMLNode.h */,
				4B11005B14329B9A003A45D8 /* OFXMLNode.m */,
				4B6799891099E7C50041064A /* OFXMLParser.h */,
				4B67998A1099E7C50041064A /* OFXMLParser.m */,
				4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */,
				4B48B95314DC23B100546D39 /* OFXMLProcessingInstructions.m */,


				4B6AF97310A8D4450003FB0A /* ObjFW.h */,
				4BB52CC817B8EA8E00B7EBF5 /* apple-forwarding-arm.S */,
				4BB52CC917B8EA8E00B7EBF5 /* apple-forwarding-i386.S */,
				4BB52CCA17B8EA8E00B7EBF5 /* apple-forwarding-ppc.S */,
				4BB52CCB17B8EA8E00B7EBF5 /* apple-forwarding-x86_64.S */,
				4B6799561099E7C50041064A /* asprintf.h */,
				4B6AF96C10A8D3E40003FB0A /* asprintf.m */,







>
>







1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
				4B0D249511DFAA3D00ED6FFC /* OFXMLElementBuilder.m */,
				4B11005A14329B9A003A45D8 /* OFXMLNode.h */,
				4B11005B14329B9A003A45D8 /* OFXMLNode.m */,
				4B6799891099E7C50041064A /* OFXMLParser.h */,
				4B67998A1099E7C50041064A /* OFXMLParser.m */,
				4B48B95214DC23B100546D39 /* OFXMLProcessingInstructions.h */,
				4B48B95314DC23B100546D39 /* OFXMLProcessingInstructions.m */,
				4BE52D1F17B990B4005958D1 /* OFZIPArchive.h */,
				4BE52D2017B990B4005958D1 /* OFZIPArchive.m */,
				4B6AF97310A8D4450003FB0A /* ObjFW.h */,
				4BB52CC817B8EA8E00B7EBF5 /* apple-forwarding-arm.S */,
				4BB52CC917B8EA8E00B7EBF5 /* apple-forwarding-i386.S */,
				4BB52CCA17B8EA8E00B7EBF5 /* apple-forwarding-ppc.S */,
				4BB52CCB17B8EA8E00B7EBF5 /* apple-forwarding-x86_64.S */,
				4B6799561099E7C50041064A /* asprintf.h */,
				4B6AF96C10A8D3E40003FB0A /* asprintf.m */,
1454
1455
1456
1457
1458
1459
1460

1461
1462
1463
1464
1465
1466
1467
				4B49EA71143B3A090005BBC6 /* OFXMLComment.h in Headers */,
				4B3D23E11337FCB000DD29B8 /* OFXMLElement.h in Headers */,
				4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */,
				4B3D23E21337FCB000DD29B8 /* OFXMLElementBuilder.h in Headers */,
				4B11005C14329B9A003A45D8 /* OFXMLNode.h in Headers */,
				4B3D23E31337FCB000DD29B8 /* OFXMLParser.h in Headers */,
				4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */,

				4B3D23E41337FCB000DD29B8 /* ObjFW.h in Headers */,
				4B3D23E51337FCB000DD29B8 /* asprintf.h in Headers */,
				4B3D23E61337FCB000DD29B8 /* atomic.h in Headers */,
				4BA9CFA415E129D30076DC74 /* autorelease.h in Headers */,
				4B3D23E71337FCB000DD29B8 /* base64.h in Headers */,
				4B837D7916829C5F007A3E83 /* block.h in Headers */,
				4B837D7A16829C5F007A3E83 /* instance.h in Headers */,







>







1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
				4B49EA71143B3A090005BBC6 /* OFXMLComment.h in Headers */,
				4B3D23E11337FCB000DD29B8 /* OFXMLElement.h in Headers */,
				4BB25E8C139C388A00F574EA /* OFXMLElement+Serialization.h in Headers */,
				4B3D23E21337FCB000DD29B8 /* OFXMLElementBuilder.h in Headers */,
				4B11005C14329B9A003A45D8 /* OFXMLNode.h in Headers */,
				4B3D23E31337FCB000DD29B8 /* OFXMLParser.h in Headers */,
				4B48B95414DC23B100546D39 /* OFXMLProcessingInstructions.h in Headers */,
				4BE52D2117B990B4005958D1 /* OFZIPArchive.h in Headers */,
				4B3D23E41337FCB000DD29B8 /* ObjFW.h in Headers */,
				4B3D23E51337FCB000DD29B8 /* asprintf.h in Headers */,
				4B3D23E61337FCB000DD29B8 /* atomic.h in Headers */,
				4BA9CFA415E129D30076DC74 /* autorelease.h in Headers */,
				4B3D23E71337FCB000DD29B8 /* base64.h in Headers */,
				4B837D7916829C5F007A3E83 /* block.h in Headers */,
				4B837D7A16829C5F007A3E83 /* instance.h in Headers */,
1475
1476
1477
1478
1479
1480
1481

1482
1483
1484
1485
1486
1487
1488
				4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */,
				4B17FF7F133A2D17003E6DCD /* OFAllocFailedException.h in Headers */,
				4B90B78D133AD46700BD33CB /* OFAlreadyConnectedException.h in Headers */,
				4B90B7A2133AD87D00BD33CB /* OFBindFailedException.h in Headers */,
				4B067FBB177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.h in Headers */,
				4B067FBD177BA6F900B8CFDA /* OFChangeOwnerFailedException.h in Headers */,
				4B067FBF177BA6F900B8CFDA /* OFChangePermissionsFailedException.h in Headers */,

				4B29BC58133AC8540004B236 /* OFConditionBroadcastFailedException.h in Headers */,
				4B29BC59133AC8540004B236 /* OFConditionSignalFailedException.h in Headers */,
				4B7FF3B4133CED6200000324 /* OFConditionStillWaitingException.h in Headers */,
				4B29BC5A133AC8540004B236 /* OFConditionWaitFailedException.h in Headers */,
				4B90B7A4133AD87D00BD33CB /* OFConnectionFailedException.h in Headers */,
				4B29BC4E133AC7DD0004B236 /* OFCopyFileFailedException.h in Headers */,
				4B29BC3F133AC4E80004B236 /* OFCreateDirectoryFailedException.h in Headers */,







>







1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
				4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */,
				4B17FF7F133A2D17003E6DCD /* OFAllocFailedException.h in Headers */,
				4B90B78D133AD46700BD33CB /* OFAlreadyConnectedException.h in Headers */,
				4B90B7A2133AD87D00BD33CB /* OFBindFailedException.h in Headers */,
				4B067FBB177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.h in Headers */,
				4B067FBD177BA6F900B8CFDA /* OFChangeOwnerFailedException.h in Headers */,
				4B067FBF177BA6F900B8CFDA /* OFChangePermissionsFailedException.h in Headers */,
				4BE52D2517B990DA005958D1 /* OFChecksumFailedException.h in Headers */,
				4B29BC58133AC8540004B236 /* OFConditionBroadcastFailedException.h in Headers */,
				4B29BC59133AC8540004B236 /* OFConditionSignalFailedException.h in Headers */,
				4B7FF3B4133CED6200000324 /* OFConditionStillWaitingException.h in Headers */,
				4B29BC5A133AC8540004B236 /* OFConditionWaitFailedException.h in Headers */,
				4B90B7A4133AD87D00BD33CB /* OFConnectionFailedException.h in Headers */,
				4B29BC4E133AC7DD0004B236 /* OFCopyFileFailedException.h in Headers */,
				4B29BC3F133AC4E80004B236 /* OFCreateDirectoryFailedException.h in Headers */,
1810
1811
1812
1813
1814
1815
1816

1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833

1834
1835
1836
1837
1838
1839
1840
				4B49EA72143B3A090005BBC6 /* OFXMLComment.m in Sources */,
				4B3D23AF1337FC0D00DD29B8 /* OFXMLElement.m in Sources */,
				4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */,
				4B3D23B01337FC0D00DD29B8 /* OFXMLElementBuilder.m in Sources */,
				4B11005D14329B9A003A45D8 /* OFXMLNode.m in Sources */,
				4B3D23B11337FC0D00DD29B8 /* OFXMLParser.m in Sources */,
				4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */,

				4B3D23B31337FC0D00DD29B8 /* base64.m in Sources */,
				4BB52CC717B8EA7F00B7EBF5 /* codepage_437.m in Sources */,
				4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */,
				4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */,
				4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */,
				4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */,
				4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */,
				4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */,
				4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */,
				4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */,
				4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */,
				4B17FF80133A2D17003E6DCD /* OFAllocFailedException.m in Sources */,
				4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */,
				4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */,
				4B067FBC177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.m in Sources */,
				4B067FBE177BA6F900B8CFDA /* OFChangeOwnerFailedException.m in Sources */,
				4B067FC0177BA6F900B8CFDA /* OFChangePermissionsFailedException.m in Sources */,

				4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */,
				4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */,
				4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */,
				4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */,
				4B90B7A5133AD87D00BD33CB /* OFConnectionFailedException.m in Sources */,
				4B29BC4F133AC7DD0004B236 /* OFCopyFileFailedException.m in Sources */,
				4B29BC40133AC4E80004B236 /* OFCreateDirectoryFailedException.m in Sources */,







>

















>







1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
				4B49EA72143B3A090005BBC6 /* OFXMLComment.m in Sources */,
				4B3D23AF1337FC0D00DD29B8 /* OFXMLElement.m in Sources */,
				4BB25E8D139C388A00F574EA /* OFXMLElement+Serialization.m in Sources */,
				4B3D23B01337FC0D00DD29B8 /* OFXMLElementBuilder.m in Sources */,
				4B11005D14329B9A003A45D8 /* OFXMLNode.m in Sources */,
				4B3D23B11337FC0D00DD29B8 /* OFXMLParser.m in Sources */,
				4B48B95514DC23B100546D39 /* OFXMLProcessingInstructions.m in Sources */,
				4BE52D2217B990B4005958D1 /* OFZIPArchive.m in Sources */,
				4B3D23B31337FC0D00DD29B8 /* base64.m in Sources */,
				4BB52CC717B8EA7F00B7EBF5 /* codepage_437.m in Sources */,
				4B3D23B41337FC0D00DD29B8 /* iso_8859_15.m in Sources */,
				4BEF2D3117A5BF5200BB8BA3 /* forwarding.S in Sources */,
				4B3D23B51337FC0D00DD29B8 /* foundation-compat.m in Sources */,
				4B3D23EE1337FFD000DD29B8 /* of_asprintf.m in Sources */,
				4BA355BA14879BDD00442EF4 /* of_strptime.m in Sources */,
				4B3D23B91337FC0D00DD29B8 /* unicode.m in Sources */,
				4B3D23BA1337FC0D00DD29B8 /* windows_1252.m in Sources */,
				4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */,
				4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */,
				4B17FF80133A2D17003E6DCD /* OFAllocFailedException.m in Sources */,
				4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */,
				4B90B7A3133AD87D00BD33CB /* OFBindFailedException.m in Sources */,
				4B067FBC177BA6F900B8CFDA /* OFChangeCurrentDirectoryPathFailedException.m in Sources */,
				4B067FBE177BA6F900B8CFDA /* OFChangeOwnerFailedException.m in Sources */,
				4B067FC0177BA6F900B8CFDA /* OFChangePermissionsFailedException.m in Sources */,
				4BE52D2617B990DA005958D1 /* OFChecksumFailedException.m in Sources */,
				4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */,
				4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */,
				4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */,
				4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */,
				4B90B7A5133AD87D00BD33CB /* OFConnectionFailedException.m in Sources */,
				4B29BC4F133AC7DD0004B236 /* OFCopyFileFailedException.m in Sources */,
				4B29BC40133AC4E80004B236 /* OFCreateDirectoryFailedException.m in Sources */,

Modified src/Makefile from [45aff8468f] to [757f467d0a].

59
60
61
62
63
64
65

66
67
68
69
70
71
72
       OFXMLComment.m			\
       OFXMLElement.m			\
       OFXMLElement+Serialization.m	\
       OFXMLElementBuilder.m		\
       OFXMLNode.m			\
       OFXMLParser.m			\
       OFXMLProcessingInstructions.m	\

       base64.m				\
       of_asprintf.m			\
       of_strptime.m			\
       unicode.m			\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_THREADS}







>







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
       OFXMLComment.m			\
       OFXMLElement.m			\
       OFXMLElement+Serialization.m	\
       OFXMLElementBuilder.m		\
       OFXMLNode.m			\
       OFXMLParser.m			\
       OFXMLProcessingInstructions.m	\
       OFZIPArchive.m			\
       base64.m				\
       of_asprintf.m			\
       of_strptime.m			\
       unicode.m			\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_THREADS}

Modified src/OFObject.m from [1d6bb87b12] to [5387ac3c3a].

1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
	while (iter != NULL) {
		struct pre_mem *next = iter->next;

		/*
		 * We can use owner as a sentinel to prevent exploitation in
		 * case there is a buffer underflow somewhere.
		 */
		if OF_UNLIKELY (iter->owner != self)
			abort();

		free(iter);

		iter = next;
	}

	free((char*)self - PRE_IVARS_ALIGN);







|
<







1069
1070
1071
1072
1073
1074
1075
1076

1077
1078
1079
1080
1081
1082
1083
	while (iter != NULL) {
		struct pre_mem *next = iter->next;

		/*
		 * We can use owner as a sentinel to prevent exploitation in
		 * case there is a buffer underflow somewhere.
		 */
		OF_ENSURE(iter->owner == self);


		free(iter);

		iter = next;
	}

	free((char*)self - PRE_IVARS_ALIGN);

Added src/OFZIPArchive.h version [58ddf733c1].













































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFString.h"

@class OFFile;
@class OFMutableArray;
@class OFMutableDictionary;
@class OFStream;

/*!
 * @brief A class for accessing and manipulating ZIP files.
 */
@interface OFZIPArchive: OFObject
{
	OFFile *_file;
	OFString *_path;
	uint16_t _diskNumber, _centralDirectoryDisk;
	uint16_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries;
	uint32_t _centralDirectorySize, _centralDirectoryOffset;
	OFString *_archiveComment;
	OFMutableArray *_filesInArchive;
	OFMutableDictionary *_fileHeaders;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFString *archiveComment;
@property (readonly, copy) OFArray *filesInArchive;
#endif

/*!
 * @brief Creates a new OFZIPArchive object for the specified file.
 *
 * @param path The path to the ZIP file
 * @return A new, autoreleased OFZIPArchive
 */
+ (instancetype)archiveWithFile: (OFString*)path;

/*!
 * @brief Initializes an already allocated OFZIPArchive object for the
 *	  specified file.
 *
 * @param path The path to the ZIP file
 * @return An Initialized OFZIPArchive
 */
- initWithFile: (OFString*)path;

/*!
 * @brief Returns an array with the names of all files in the archive.
 *
 * @return An array with the names of all files in the archive
 */
- (OFArray*)filesInArchive;

/*!
 * @brief Returns the archive comment.
 *
 * @return The archive comment
 */
- (OFString*)archiveComment;

/*!
 * @brief Returns a stream for reading the specified file from the archive.
 *
 * @param path The path to the file inside the archive
 * @return A stream for reading the specified file form the archive
 */
- (OFStream*)streamForReadingFile: (OFString*)path;

- (void)OF_readZIPInfo;
- (void)OF_readFileHeaders;
@end

Added src/OFZIPArchive.m version [f436d4f99e].

































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdio.h>

#import "OFZIPArchive.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFFile.h"

#import "OFChecksumFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFReadFailedException.h"
#import "OFUnsupportedVersionException.h"

#import "autorelease.h"
#import "macros.h"

#define CRC32_MAGIC 0xEDB88320

/*
 * FIXME: Current limitations:
 *  - Compressed files cannot be read.
 *  - Encrypted files cannot be read.
 *  - Split archives are not supported.
 *  - Write support is missing.
 *  - The ZIP has to be a file on the local file system.
 *  - No support for ZIP64.
 */

@interface OFZIPArchive_FileHeader: OFObject
{
@public
	uint16_t _madeWithVersion, _minVersion, _generalPurposeBitFlag;
	uint16_t _compressionMethod, _lastModifiedFileTime;
	uint16_t _lastModifiedFileDate;
	uint32_t _CRC32, _compressedSize, _uncompressedSize;
	OFString *_fileName;
	OFDataArray *_extraField;
	OFString *_fileComment;
	uint16_t _startDiskNumber, _internalAttributes;
	uint32_t _externalAttributes, _localFileHeaderOffset;
}

- initWithFile: (OFFile*)file;
@end

@interface OFZIPArchive_LocalFileHeader: OFObject
{
@public
	uint16_t _minVersion, _generalPurposeBitFlag, _compressionMethod;
	uint16_t _lastModifiedFileTime, _lastModifiedFileDate;
	uint32_t _CRC32, _compressedSize, _uncompressedSize;
	OFString *_fileName;
	OFDataArray *_extraField;
}

- initWithFile: (OFFile*)file;
- (bool)matchesFileHeader: (OFZIPArchive_FileHeader*)fileHeader;
@end

@interface OFZIPArchive_FileStream: OFStream
{
	OFFile *_file;
	size_t _size;
	uint32_t _expectedCRC32, _CRC32;
	bool _atEndOfStream;
}

- initWithArchiveFile: (OFString*)path
	       offset: (off_t)offset
		 size: (size_t)size
		CRC32: (uint32_t)CRC32;
@end

static uint32_t
crc32(uint32_t crc, uint8_t *bytes, size_t length)
{
	size_t i;

	for (i = 0; i < length; i++) {
		uint_fast8_t j;

		crc ^= bytes[i];

		for (j = 0; j < 8; j++)
			crc = (crc >> 1) ^ (CRC32_MAGIC & (~(crc & 1) + 1));
	}

	return crc;
}

@implementation OFZIPArchive
+ (instancetype)archiveWithFile: (OFString*)path
{
	return [[[self alloc] initWithFile: path] autorelease];
}

- initWithFile: (OFString*)path
{
	self = [super init];

	@try {
		_file = [[OFFile alloc] initWithPath: path
						mode: @"rb"];
		_path = [path copy];

		[self OF_readZIPInfo];
		[self OF_readFileHeaders];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_file release];
	[_path release];
	[_archiveComment release];
	[_filesInArchive release];
	[_fileHeaders release];

	[super dealloc];
}

- (void)OF_readZIPInfo
{
	void *pool = objc_autoreleasePoolPush();
	uint16_t commentLength;

	[_file seekToOffset: -22
		     whence: SEEK_END];

	if ([_file readLittleEndianInt32] != 0x06054B50)
		@throw [OFInvalidFormatException exception];

	_diskNumber = [_file readLittleEndianInt16],
	_centralDirectoryDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntriesInDisk = [_file readLittleEndianInt16];
	_centralDirectoryEntries = [_file readLittleEndianInt16];
	_centralDirectorySize = [_file readLittleEndianInt32];
	_centralDirectoryOffset = [_file readLittleEndianInt32];

	commentLength = [_file readLittleEndianInt16];
	_archiveComment = [[_file
	    readStringWithLength: commentLength
			encoding: OF_STRING_ENCODING_CODEPAGE_437] copy];

	objc_autoreleasePoolPop(pool);
}

- (void)OF_readFileHeaders
{
	void *pool = objc_autoreleasePoolPush();
	size_t i;

	[_file seekToOffset: _centralDirectoryOffset
		     whence: SEEK_SET];

	_filesInArchive = [[OFMutableArray alloc] init];
	_fileHeaders = [[OFMutableDictionary alloc] init];

	for (i = 0; i < _centralDirectoryEntries; i++) {
		OFZIPArchive_FileHeader *fileHeader =
		    [[[OFZIPArchive_FileHeader alloc]
		    initWithFile: _file] autorelease];

		[_filesInArchive addObject: fileHeader->_fileName];
		[_fileHeaders setObject: fileHeader
				 forKey: fileHeader->_fileName];
	}

	[_filesInArchive makeImmutable];
	[_fileHeaders makeImmutable];

	objc_autoreleasePoolPop(pool);
}

- (OFArray*)filesInArchive
{
	OF_GETTER(_filesInArchive, true)
}

- (OFString*)archiveComment
{
	OF_GETTER(_archiveComment, true)
}

- (OFStream*)streamForReadingFile: (OFString*)path
{
	OFStream *ret;
	void *pool = objc_autoreleasePoolPush();
	OFZIPArchive_FileHeader *fileHeader = [_fileHeaders objectForKey: path];
	OFZIPArchive_LocalFileHeader *localFileHeader;

	if (fileHeader == nil) {
		errno = ENOENT;
		@throw [OFOpenFileFailedException exceptionWithPath: path
							       mode: @"rb"];
	}

	[_file seekToOffset: fileHeader->_localFileHeaderOffset
		     whence: SEEK_SET];
	localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc]
	    initWithFile: _file] autorelease];

	if (![localFileHeader matchesFileHeader: fileHeader])
		@throw [OFInvalidFormatException exception];

	if (localFileHeader->_minVersion > 10) {
		OFString *version = [OFString stringWithFormat: @"%u.%u",
		    localFileHeader->_minVersion / 10,
		    localFileHeader->_minVersion % 10];

		@throw [OFUnsupportedVersionException
		    exceptionWithVersion: version];
	}

	if (localFileHeader->_compressionMethod != 0)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	ret = [[OFZIPArchive_FileStream alloc]
	    initWithArchiveFile: _path
			 offset: [_file seekToOffset: 0
					      whence: SEEK_CUR]
			   size: localFileHeader->_uncompressedSize
			  CRC32: localFileHeader->_CRC32];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end

@implementation OFZIPArchive_FileHeader
- initWithFile: (OFFile*)file
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		uint16_t fileNameLength, extraFieldLength, fileCommentLength;
		of_string_encoding_t encoding;

		if ([file readLittleEndianInt32] != 0x02014B50)
			@throw [OFInvalidFormatException exception];

		_madeWithVersion = [file readLittleEndianInt16];
		_minVersion = [file readLittleEndianInt16];
		_generalPurposeBitFlag = [file readLittleEndianInt16];
		_compressionMethod = [file readLittleEndianInt16];
		_lastModifiedFileTime = [file readLittleEndianInt16];
		_lastModifiedFileDate = [file readLittleEndianInt16];
		_CRC32 = [file readLittleEndianInt32];
		_compressedSize = [file readLittleEndianInt32];
		_uncompressedSize = [file readLittleEndianInt32];
		fileNameLength = [file readLittleEndianInt16];
		extraFieldLength = [file readLittleEndianInt16];
		fileCommentLength = [file readLittleEndianInt16];
		_startDiskNumber = [file readLittleEndianInt16];
		_internalAttributes = [file readLittleEndianInt16];
		_externalAttributes = [file readLittleEndianInt32];
		_localFileHeaderOffset = [file readLittleEndianInt32];

		encoding = (_generalPurposeBitFlag & (1 << 11)
		    ? OF_STRING_ENCODING_UTF_8
		    : OF_STRING_ENCODING_CODEPAGE_437);

		_fileName = [[file readStringWithLength: fileNameLength
					       encoding: encoding] copy];
		_extraField = [[file
		    readDataArrayWithCount: extraFieldLength] retain];
		_fileComment = [[file readStringWithLength: fileCommentLength
						  encoding: encoding] copy];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_fileName release];
	[_extraField release];
	[_fileComment release];

	[super dealloc];
}
@end

@implementation OFZIPArchive_LocalFileHeader
- initWithFile: (OFFile*)file
{
	self = [super init];

	@try {
		uint16_t fileNameLength, extraFieldLength;
		of_string_encoding_t encoding;

		if ([file readLittleEndianInt32] != 0x04034B50)
			@throw [OFInvalidFormatException exception];

		_minVersion = [file readLittleEndianInt16];
		_generalPurposeBitFlag = [file readLittleEndianInt16];
		_compressionMethod = [file readLittleEndianInt16];
		_lastModifiedFileTime = [file readLittleEndianInt16];
		_lastModifiedFileDate = [file readLittleEndianInt16];
		_CRC32 = [file readLittleEndianInt32];
		_compressedSize = [file readLittleEndianInt32];
		_uncompressedSize = [file readLittleEndianInt32];
		fileNameLength = [file readLittleEndianInt16];
		extraFieldLength = [file readLittleEndianInt16];
		encoding = (_generalPurposeBitFlag & (1 << 11)
		    ? OF_STRING_ENCODING_UTF_8
		    : OF_STRING_ENCODING_CODEPAGE_437);

		_fileName = [[file readStringWithLength: fileNameLength
					       encoding: encoding] copy];
		_extraField = [[file
		    readDataArrayWithCount: extraFieldLength] retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_fileName release];
	[_extraField release];

	[super dealloc];
}

- (bool)matchesFileHeader: (OFZIPArchive_FileHeader*)fileHeader
{
	if (_minVersion != fileHeader->_minVersion ||
	    _generalPurposeBitFlag != fileHeader->_generalPurposeBitFlag ||
	    _compressionMethod != fileHeader->_compressionMethod ||
	    _lastModifiedFileTime != fileHeader->_lastModifiedFileTime ||
	    _lastModifiedFileDate != fileHeader->_lastModifiedFileDate ||
	    _CRC32 != fileHeader->_CRC32 ||
	    _compressedSize != fileHeader->_compressedSize ||
	    _uncompressedSize != fileHeader->_uncompressedSize ||
	    ![_fileName isEqual: fileHeader->_fileName])
		return false;

	return true;
}

@end

@implementation OFZIPArchive_FileStream
- initWithArchiveFile: (OFString*)path
	       offset: (off_t)offset
		 size: (size_t)size
		CRC32: (uint32_t)CRC32
{
	self = [super init];

	@try {
		_file = [[OFFile alloc] initWithPath: path
						mode: @"rb"];
		[_file seekToOffset: offset
			     whence: SEEK_SET];

		_size = size;
		_CRC32 = ~0;
		_expectedCRC32 = CRC32;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_file release];

	[super dealloc];
}

- (bool)lowlevelIsAtEndOfStream
{
	return _atEndOfStream;
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer
			  length: (size_t)length
{
	size_t min, ret;

	if (_atEndOfStream)
		@throw [OFReadFailedException exceptionWithStream: self
						  requestedLength: length];

	if (_size == 0) {
		_atEndOfStream = true;

		if (~_CRC32 != _expectedCRC32)
			@throw [OFChecksumFailedException exception];

		return 0;
	}

	if (length < _size)
		min = length;
	else
		min = _size;

	ret = [_file readIntoBuffer: buffer
			     length: min];
	_size -= ret;
	_CRC32 = crc32(_CRC32, buffer, ret);

	return ret;
}
@end

Modified src/ObjFW.h from [7016b0c88a] to [3262ca71e0].

43
44
45
46
47
48
49

50
51
52
53
54
55
56
#import "OFNumber.h"
#import "OFDate.h"
#import "OFURL.h"

#import "OFStream.h"
#import "OFStdIOStream.h"
#import "OFFile.h"

#ifdef OF_HAVE_SOCKETS
# import "OFStreamSocket.h"
# import "OFTCPSocket.h"
# import "OFTLSSocket.h"
# import "OFStreamObserver.h"

# import "OFHTTPRequest.h"







>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "OFNumber.h"
#import "OFDate.h"
#import "OFURL.h"

#import "OFStream.h"
#import "OFStdIOStream.h"
#import "OFFile.h"
#import "OFZIPArchive.h"
#ifdef OF_HAVE_SOCKETS
# import "OFStreamSocket.h"
# import "OFTCPSocket.h"
# import "OFTLSSocket.h"
# import "OFStreamObserver.h"

# import "OFHTTPRequest.h"

Modified src/exceptions/Makefile from [c7c844bb16] to [99a0658ee8].

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
include ../../extra.mk

STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A}
STATIC_LIB_NOINST = ${EXCEPTIONS_A}

SRCS = OFAllocFailedException.m				\
       OFChangeCurrentDirectoryPathFailedException.m	\
       OFChangeOwnerFailedException.m			\
       OFChangePermissionsFailedException.m		\

       OFCopyFileFailedException.m			\
       OFCreateDirectoryFailedException.m		\
       OFCreateSymbolicLinkFailedException.m		\
       OFEnumerationMutationException.m			\
       OFException.m					\
       OFHashAlreadyCalculatedException.m		\
       OFInitializationFailedException.m		\









>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
include ../../extra.mk

STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A}
STATIC_LIB_NOINST = ${EXCEPTIONS_A}

SRCS = OFAllocFailedException.m				\
       OFChangeCurrentDirectoryPathFailedException.m	\
       OFChangeOwnerFailedException.m			\
       OFChangePermissionsFailedException.m		\
       OFChecksumFailedException.m			\
       OFCopyFileFailedException.m			\
       OFCreateDirectoryFailedException.m		\
       OFCreateSymbolicLinkFailedException.m		\
       OFEnumerationMutationException.m			\
       OFException.m					\
       OFHashAlreadyCalculatedException.m		\
       OFInitializationFailedException.m		\

Added src/exceptions/OFChecksumFailedException.h version [fa48d9c342].















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

/*!
 * @brief An exception indicating that a checksum did not match.
 */
@interface OFChecksumFailedException: OFException
@end

Added src/exceptions/OFChecksumFailedException.m version [2df4011a84].























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFChecksumFailedException.h"
#import "OFString.h"

@implementation OFChecksumFailedException
- (OFString*)description
{
	return @"Checksum mismatch!";
}
@end