| 956 | } |
| 957 | |
| 958 | int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) |
| 959 | { |
| 960 | /* write the local header */ |
| 961 | int err; |
| 962 | uInt size_filename = (uInt)strlen(filename); |
| 963 | uInt size_extrafield = size_extrafield_local; |
| 964 | |
| 965 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4); |
| 966 | |
| 967 | if (err==ZIP_OK) |
| 968 | { |
| 969 | if(zi->ci.zip64) |
| 970 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ |
| 971 | else |
| 972 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ |
| 973 | } |
| 974 | |
| 975 | if (err==ZIP_OK) |
| 976 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); |
| 977 | |
| 978 | if (err==ZIP_OK) |
| 979 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); |
| 980 | |
| 981 | if (err==ZIP_OK) |
| 982 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); |
| 983 | |
| 984 | // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later |
| 985 | if (err==ZIP_OK) |
| 986 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ |
| 987 | if (err==ZIP_OK) |
| 988 | { |
| 989 | if(zi->ci.zip64) |
| 990 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */ |
| 991 | else |
| 992 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ |
| 993 | } |
| 994 | if (err==ZIP_OK) |
| 995 | { |
| 996 | if(zi->ci.zip64) |
| 997 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */ |
| 998 | else |
| 999 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ |
| 1000 | } |
| 1001 | |
| 1002 | if (err==ZIP_OK) |
| 1003 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); |
| 1004 | |
| 1005 | if(zi->ci.zip64) |
| 1006 | { |
| 1007 | size_extrafield += 20; |
| 1008 | } |
| 1009 | |
| 1010 | if (err==ZIP_OK) |
| 1011 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2); |
| 1012 | |
| 1013 | if ((err==ZIP_OK) && (size_filename > 0)) |
| 1014 | { |
| 1015 | if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) |
no test coverage detected