| 970 | } |
| 971 | |
| 972 | int Write_LocalFileHeader(zip64_internal* zi, const char* filename, |
| 973 | uInt size_extrafield_local, |
| 974 | const void* extrafield_local, |
| 975 | uLong version_to_extract) |
| 976 | { |
| 977 | /* write the local header */ |
| 978 | int err; |
| 979 | uInt size_filename = (uInt)strlen(filename); |
| 980 | uInt size_extrafield = size_extrafield_local; |
| 981 | |
| 982 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4); |
| 983 | |
| 984 | if (err==ZIP_OK) |
| 985 | { |
| 986 | if(zi->ci.flag & ZIP_ENCODING_UTF8) |
| 987 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)63,2);/* Version 6.3 is required for Unicode support */ |
| 988 | else if(zi->ci.zip64) |
| 989 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ |
| 990 | else |
| 991 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,version_to_extract,2); |
| 992 | } |
| 993 | |
| 994 | if (err==ZIP_OK) |
| 995 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,zi->ci.flag,2); |
| 996 | |
| 997 | if (err==ZIP_OK) |
| 998 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); |
| 999 | |
| 1000 | if (err==ZIP_OK) |
| 1001 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,zi->ci.dosDate,4); |
| 1002 | |
| 1003 | /* CRC / Compressed size / Uncompressed size will be filled in later and rewritten later */ |
| 1004 | if (err==ZIP_OK) |
| 1005 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ |
| 1006 | if (err==ZIP_OK) |
| 1007 | { |
| 1008 | if(zi->ci.zip64) |
| 1009 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */ |
| 1010 | else |
| 1011 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ |
| 1012 | } |
| 1013 | if (err==ZIP_OK) |
| 1014 | { |
| 1015 | if(zi->ci.zip64) |
| 1016 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */ |
| 1017 | else |
| 1018 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ |
| 1019 | } |
| 1020 | |
| 1021 | if (err==ZIP_OK) |
| 1022 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); |
| 1023 | |
| 1024 | if(zi->ci.zip64) |
| 1025 | { |
| 1026 | size_extrafield += 20; |
| 1027 | } |
| 1028 | |
| 1029 | if (err==ZIP_OK) |
no test coverage detected