public static int zipOpenNewFileInZip4_64(IntPtr handle, byte[] entryName, ref ZipFileEntryInfo entryInfoPtr, byte[] extraField, uint extraFieldLength, byte[] extraFieldGlobal, uint extraFieldGlobalLength, byte[] comment, int method, int level, uint flagBase, bool zip64 ) { if (Is64) { return(zipOpenNewFileInZip4_64_64(handle, entryName, ref entryInfoPtr, extraField, extraFieldLength, extraFieldGlobal, extraFieldGlobalLength, comment, method, level, 0, -ZLib.MAX_WBITS, ZLib.DEF_MEM_LEVEL, ZLib.Z_DEFAULT_STRATEGY, null, 0, ZLib.VERSIONMADEBY, flagBase, zip64 ? 1 : 0)); } else { return(zipOpenNewFileInZip4_64_32(handle, entryName, ref entryInfoPtr, extraField, extraFieldLength, extraFieldGlobal, extraFieldGlobalLength, comment, method, level, 0, -ZLib.MAX_WBITS, ZLib.DEF_MEM_LEVEL, ZLib.Z_DEFAULT_STRATEGY, null, 0, ZLib.VERSIONMADEBY, flagBase, zip64 ? 1 : 0)); } }
static extern int zipOpenNewFileInZip4_64_32(IntPtr handle, byte[] entryName, ref ZipFileEntryInfo entryInfoPtr, byte[] extraField, uint extraFieldLength, byte[] extraFieldGlobal, uint extraFieldGlobalLength, byte[] comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, byte[] password, uint crcForCrypting, uint versionMadeBy, uint flagBase, int zip64);
/// <summary>Creates a new zip entry in the directory and positions the stream to the start of the entry data.</summary> /// <param name="entry">The zip entry to be written.</param> /// <remarks>Closes the current entry if still active.</remarks> public void AddEntry(ZipEntry entry) { //Close previous entry (if any). //Will trigger write of central dir info for previous file and may throw. CloseCurrentEntry(); ZipFileEntryInfo info = new ZipFileEntryInfo(); info.ZipDateTime = entry.ModifiedTime; info.ExternalFileAttributes = (uint)entry.GetFileAttributesForZip(); byte[] extra = null; uint extraLength = 0; if (entry.ExtraField != null) { extra = entry.ExtraField; extraLength = (uint)entry.ExtraField.Length; } string nameForZip = entry.GetNameForZip(); uint flagBase = 0; if (entry.UTF8Encoding) { flagBase |= ZipEntryFlag.UTF8; } else { if (!nameForZip.IsAscii()) { throw new ArgumentException("Name can only contain Ascii 8 bit characters."); } if (entry.Comment != null && !entry.Comment.IsAscii()) { throw new ArgumentException("Comment can only contain Ascii 8 bit characters."); } } Encoding encoding = entry.UTF8Encoding ? Encoding.UTF8 : Minizip.OEMEncoding; byte[] name = encoding.GetBytes(nameForZip + Char.MinValue); // add nullterm byte[] comment = null; if (entry.Comment != null) { comment = encoding.GetBytes(entry.Comment + Char.MinValue); // add nullterm } int result = Minizip.zipOpenNewFileInZip4_64( _handle, name, ref info, extra, extraLength, null, 0, comment, //null is ok here (int)entry.Method, entry.Level, flagBase, entry.Zip64); if (result < 0) { throw new ZipException("AddEntry error.", result); } _current = entry; }