System.Windows.Threading/DispatcherUnhandledExceptionEventHandler.cs
System.Windows.Threading/DispatcherUnhandledExceptionFilterEventArgs.cs
System.Windows.Threading/DispatcherUnhandledExceptionFilterEventHandler.cs
+ZipSharp/NativeVersion.cs
ZipSharp/IOFunctions.cs
ZipSharp/ZipArchive.cs
ZipSharp/UnzipArchive.cs
internal delegate IntPtr OpenFileFunc (IntPtr opaque, string filename, int mode);
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
- internal delegate /* ulong */ IntPtr ReadFileFunc (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ IntPtr size);
+ internal delegate /* uLong */ uint ReadFileFunc32 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* uLong */ uint size);
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
- internal delegate /* ulong */ IntPtr WriteFileFunc (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ IntPtr size);
+ internal delegate /* uLong */ uint WriteFileFunc32 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* uLong */ uint size);
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
- internal delegate /* long */ IntPtr TellFileFunc (IntPtr opaque, IntPtr stream);
+ internal delegate /* long */ int TellFileFunc32 (IntPtr opaque, IntPtr stream);
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
- internal delegate /* long */ IntPtr SeekFileFunc (IntPtr opaque, IntPtr stream, /* ulong */ IntPtr offset, int origin);
+ internal delegate /* long */ int SeekFileFunc32 (IntPtr opaque, IntPtr stream, /* uLong */ uint offset, int origin);
+
+ [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
+ internal delegate /* uLong */ ulong ReadFileFunc64 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* uLong */ ulong size);
+
+ [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
+ internal delegate /* uLong */ ulong WriteFileFunc64 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* uLong */ ulong size);
+
+ [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
+ internal delegate /* long */ long TellFileFunc64 (IntPtr opaque, IntPtr stream);
+
+ [UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
+ internal delegate /* long */ long SeekFileFunc64 (IntPtr opaque, IntPtr stream, /* uLong */ ulong offset, int origin);
[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
internal delegate int CloseFileFunc (IntPtr opaque, IntPtr stream);
internal delegate int TestErrorFileFunc (IntPtr opaque, IntPtr stream);
[StructLayout (LayoutKind.Sequential)]
- internal struct ZlibFileFuncDef
+ internal struct ZlibFileFuncDef32
+ {
+ [MarshalAs (UnmanagedType.FunctionPtr)] public OpenFileFunc zopen_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public ReadFileFunc32 zread_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public WriteFileFunc32 zwrite_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public TellFileFunc32 ztell_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public SeekFileFunc32 zseek_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public CloseFileFunc zclose_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public TestErrorFileFunc zerror_file;
+ public IntPtr opaque;
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct ZlibFileFuncDef64
{
[MarshalAs (UnmanagedType.FunctionPtr)] public OpenFileFunc zopen_file;
- [MarshalAs (UnmanagedType.FunctionPtr)] public ReadFileFunc zread_file;
- [MarshalAs (UnmanagedType.FunctionPtr)] public WriteFileFunc zwrite_file;
- [MarshalAs (UnmanagedType.FunctionPtr)] public TellFileFunc ztell_file;
- [MarshalAs (UnmanagedType.FunctionPtr)] public SeekFileFunc zseek_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public ReadFileFunc64 zread_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public WriteFileFunc64 zwrite_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public TellFileFunc64 ztell_file;
+ [MarshalAs (UnmanagedType.FunctionPtr)] public SeekFileFunc64 zseek_file;
[MarshalAs (UnmanagedType.FunctionPtr)] public CloseFileFunc zclose_file;
[MarshalAs (UnmanagedType.FunctionPtr)] public TestErrorFileFunc zerror_file;
public IntPtr opaque;
return unztell(handle).ToInt64 ();
}
- public static long CurrentFileLength (UnzipHandle handle)
+ public static long CurrentFileLength32 (UnzipHandle handle)
{
- UnzipFileInfo info;
- int result = unzGetCurrentFileInfo (handle, out info, null, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, null, IntPtr.Zero);
-
- if (result != 0)
- return -1;
- else
- return (long)info.UncompressedSize;
+ UnzipFileInfo32 info;
+ int result = unzGetCurrentFileInfo_32 (handle, out info, null, 0, IntPtr.Zero, 0, null, 0);
+ return result != 0 ? -1 : (long) info.uncompressed_size;
}
-
- static string GetCurrentFileName (UnzipHandle handle)
+
+ public static long CurrentFileLength64 (UnzipHandle handle)
{
- UnzipFileInfo info;
- int result = unzGetCurrentFileInfo (handle, out info, null, IntPtr.Zero, IntPtr.Zero, new IntPtr (0), null, IntPtr.Zero);
+ UnzipFileInfo64 info;
+ int result = unzGetCurrentFileInfo_64 (handle, out info, null, 0, IntPtr.Zero, 0, null, 0);
+ return result != 0 ? -1 : (long) info.uncompressed_size;
+ }
- if (result != 0)
+ static string GetCurrentFileName32 (UnzipHandle handle)
+ {
+ UnzipFileInfo32 info;
+ if (unzGetCurrentFileInfo_32 (handle, out info, null, 0, IntPtr.Zero, 0, null, 0) != 0)
return null;
-
- StringBuilder sbName = new StringBuilder ((int)info.SizeFilename+1); // +1 to account for extra \0 at the end
- result = unzGetCurrentFileInfo (handle, out info, sbName, new IntPtr (sbName.Capacity), IntPtr.Zero, new IntPtr (0), null, IntPtr.Zero);
-
- if (result != 0)
+ var sbName = new StringBuilder ((int) info.size_filename + 1); // +1 to account for extra \0 at the end
+ if (unzGetCurrentFileInfo_32 (handle, out info, sbName, (uint) sbName.Capacity, IntPtr.Zero, 0, null, 0) != 0)
return null;
- else
- return sbName.ToString ();
+ return sbName.ToString ();
}
- public static string[] GetFiles (UnzipHandle handle)
+ static string GetCurrentFileName64 (UnzipHandle handle)
{
- List<string> files = new List<string> ();
+ UnzipFileInfo64 info;
+ if (unzGetCurrentFileInfo_64 (handle, out info, null, 0, IntPtr.Zero, 0, null, 0) != 0)
+ return null;
+ var sbName = new StringBuilder ((int) info.size_filename + 1); // +1 to account for extra \0 at the end
+ if (unzGetCurrentFileInfo_64 (handle, out info, sbName, (uint) sbName.Capacity, IntPtr.Zero, 0, null, 0) != 0)
+ return null;
+ return sbName.ToString ();
+ }
- GoToFirstFile (handle);
+ public static string[] GetFiles32 (UnzipHandle handle)
+ {
+ return GetFiles (handle, GetCurrentFileName32);
+ }
+
+ public static string[] GetFiles64 (UnzipHandle handle)
+ {
+ return GetFiles (handle, GetCurrentFileName64);
+ }
+ private static string[] GetFiles (UnzipHandle handle, Func<UnzipHandle, string> getCurrentFileName)
+ {
+ GoToFirstFile (handle);
+ var files = new List<string> ();
string name;
- while ((name = GetCurrentFileName(handle)) != null)
- {
+ while ((name = getCurrentFileName (handle)) != null) {
files.Add (name);
if (!NativeUnzip.GoToNextFile (handle))
break;
return unzGoToNextFile(handle) == 0;
}
- public static UnzipHandle OpenArchive (ZlibFileFuncDef fileFuncs)
+ public static UnzipHandle OpenArchive32 (ZlibFileFuncDef32 fileFuncs)
+ {
+ UnzipHandle handle = unzOpen2_32 ("", ref fileFuncs);
+ if (handle.IsInvalid)
+ throw new Exception ("Could not open unzip archive");
+ return handle;
+ }
+
+ public static UnzipHandle OpenArchive64 (ZlibFileFuncDef64 fileFuncs)
{
- UnzipHandle handle = unzOpen2 ("", ref fileFuncs);
+ UnzipHandle handle = unzOpen2_64 ("", ref fileFuncs);
if (handle.IsInvalid)
throw new Exception ("Could not open unzip archive");
return handle;
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
static extern int unzGoToFirstFile (UnzipHandle handle);
- [DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
- static extern UnzipHandle unzOpen2 (string path,
- ref ZlibFileFuncDef pzlib_filefunc_def);
+ [DllImport ("MonoPosixHelper", EntryPoint="unzOpen2", CallingConvention=CallingConvention.Cdecl)]
+ static extern UnzipHandle unzOpen2_32 (string path,
+ ref ZlibFileFuncDef32 pzlib_filefunc_def);
+
+ [DllImport ("MonoPosixHelper", EntryPoint="unzOpen2", CallingConvention=CallingConvention.Cdecl)]
+ static extern UnzipHandle unzOpen2_64 (string path,
+ ref ZlibFileFuncDef64 pzlib_filefunc_def);
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
static extern int unzGoToNextFile (UnzipHandle handle);
out int level,
int raw);
- [DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
- static extern int unzGetCurrentFileInfo (UnzipHandle handle,
- out UnzipFileInfo pfile_info,
- StringBuilder szFileName,
- IntPtr fileNameBufferSize, // uLong
- IntPtr extraField, // void *
- IntPtr extraFieldBufferSize, // uLong
- StringBuilder szComment,
- IntPtr commentBufferSize); // uLong
+ [DllImport ("MonoPosixHelper", EntryPoint="unzGetCurrentFileInfo", CallingConvention=CallingConvention.Cdecl)]
+ static extern int unzGetCurrentFileInfo_32 (UnzipHandle handle,
+ out UnzipFileInfo32 pfile_info,
+ StringBuilder szFileName,
+ uint fileNameBufferSize, // uLong
+ IntPtr extraField, // void *
+ uint extraFieldBufferSize, // uLong
+ StringBuilder szComment,
+ uint commentBufferSize); // uLong
+
+ [DllImport ("MonoPosixHelper", EntryPoint="unzGetCurrentFileInfo", CallingConvention=CallingConvention.Cdecl)]
+ static extern int unzGetCurrentFileInfo_64 (UnzipHandle handle,
+ out UnzipFileInfo64 pfile_info,
+ StringBuilder szFileName,
+ ulong fileNameBufferSize, // uLong
+ IntPtr extraField, // void *
+ ulong extraFieldBufferSize, // uLong
+ StringBuilder szComment,
+ ulong commentBufferSize); // uLong
[DllImport ("MonoPosixHelper", CallingConvention=CallingConvention.Cdecl)]
static unsafe extern int unzReadCurrentFile (UnzipHandle handle,
--- /dev/null
+using System;
+
+namespace zipsharp {
+ static class NativeVersion {
+
+ /// <summary>
+ /// ZipSharp code needs different code paths
+ /// depending on the size of the C long type on the underlying platform. On
+ /// gcc/clang the C long type follows the bitness of the targeted architecture,
+ /// it's 32-bit on 32-bit systems and 64-bit on 64-bit systems. With the VS
+ /// compiler however, the C long type is always 32-bit regardless of the
+ /// target architecture. zlib and minizip uses C long in a number of
+ /// different function signatures and structs.
+ ///
+ /// This field is used to easily determine if the 32 bit version of
+ /// functions and structs should be used when interacting with zlib.
+ /// </summary>
+ public static readonly bool Use32Bit = IntPtr.Size == 4 || Environment.OSVersion.Platform != PlatformID.Unix;
+ }
+}
zipCloseFileInZip (handle);
}
- public static ZipHandle OpenArchive (ZlibFileFuncDef funcDef, Append append)
+ public static ZipHandle OpenArchive32 (ZlibFileFuncDef32 funcDef, Append append)
{
- ZipHandle h = zipOpen2 ("", (int) append, IntPtr.Zero, ref funcDef);
+ ZipHandle h = zipOpen2_32 ("", (int) append, IntPtr.Zero, ref funcDef);
if (h.IsInvalid)
throw new Exception ("Could not open the zip archive");
return h;
}
-
- public static int OpenFile (ZipHandle handle, string filename)
+
+ public static ZipHandle OpenArchive64 (ZlibFileFuncDef64 funcDef, Append append)
+ {
+ ZipHandle h = zipOpen2_64 ("", (int) append, IntPtr.Zero, ref funcDef);
+ if (h.IsInvalid)
+ throw new Exception ("Could not open the zip archive");
+ return h;
+ }
+
+ public static int OpenFile32 (ZipHandle handle, string filename)
+ {
+ return OpenFile32 (handle, filename, DEFAULT_COMPRESSION);
+ }
+
+ public static int OpenFile32 (ZipHandle handle, string filename, int compressionLevel)
+ {
+ ZipFileInfo32 fileInfo = new ZipFileInfo32 (DateTime.Now);
+ int method = compressionLevel == 0 ? 0 : Z_DEFLATED;
+ return zipOpenNewFileInZip_32 (handle, filename, ref fileInfo, IntPtr.Zero, 0, IntPtr.Zero, 0, "", method, compressionLevel);
+ }
+
+ public static int OpenFile64 (ZipHandle handle, string filename)
{
- return OpenFile (handle, filename, DEFAULT_COMPRESSION);
+ return OpenFile64 (handle, filename, DEFAULT_COMPRESSION);
}
- public static int OpenFile (ZipHandle handle, string filename, int compressionLevel)
+ public static int OpenFile64 (ZipHandle handle, string filename, int compressionLevel)
{
- ZipFileInfo fileInfo = new ZipFileInfo (DateTime.Now);
+ ZipFileInfo64 fileInfo = new ZipFileInfo64 (DateTime.Now);
int method = compressionLevel == 0 ? 0 : Z_DEFLATED;
- return zipOpenNewFileInZip (handle, filename, ref fileInfo, IntPtr.Zero, 0, IntPtr.Zero, 0, "", method, compressionLevel);
+ return zipOpenNewFileInZip_64 (handle, filename, ref fileInfo, IntPtr.Zero, 0, IntPtr.Zero, 0, "", method, compressionLevel);
}
public static unsafe void Write (ZipHandle handle, byte[] buffer, int offset, uint count)
[DllImport ("MonoPosixHelper")]
static extern int zipCloseFileInZip (ZipHandle handle);
- [DllImport ("MonoPosixHelper")]
- static extern ZipHandle zipOpen2 (string pathname,
- int append,
- IntPtr globalcomment, // zipcharpc*
- ref ZlibFileFuncDef pzlib_filefunc_def); // zlib_filefunc_def*
+ [DllImport ("MonoPosixHelper", EntryPoint = "zipOpen2")]
+ static extern ZipHandle zipOpen2_32 (string pathname,
+ int append,
+ IntPtr globalcomment, // zipcharpc*
+ ref ZlibFileFuncDef32 pzlib_filefunc_def); // zlib_filefunc_def*
+
+ [DllImport ("MonoPosixHelper", EntryPoint = "zipOpen2")]
+ static extern ZipHandle zipOpen2_64 (string pathname,
+ int append,
+ IntPtr globalcomment, // zipcharpc*
+ ref ZlibFileFuncDef64 pzlib_filefunc_def); // zlib_filefunc_def*
-
[DllImport ("MonoPosixHelper")]
static extern int zipClose (ZipHandle handle, string globalComment);
- [DllImport ("MonoPosixHelper")]
- static extern int zipOpenNewFileInZip (ZipHandle handle,
- string filename,
- ref ZipFileInfo zipfi,
- IntPtr extrafield_local,
- uint size_extrafield_local,
- IntPtr extrafield_global,
- uint size_extrafield_global,
- string comment,
- int method,
- int level);
+ [DllImport ("MonoPosixHelper", EntryPoint = "zipOpenNewFileInZip")]
+ static extern int zipOpenNewFileInZip_32 (ZipHandle handle,
+ string filename,
+ ref ZipFileInfo32 zipfi,
+ IntPtr extrafield_local,
+ uint size_extrafield_local,
+ IntPtr extrafield_global,
+ uint size_extrafield_global,
+ string comment,
+ int method,
+ int level);
+
+ [DllImport ("MonoPosixHelper", EntryPoint = "zipOpenNewFileInZip")]
+ static extern int zipOpenNewFileInZip_64 (ZipHandle handle,
+ string filename,
+ ref ZipFileInfo64 zipfi,
+ IntPtr extrafield_local,
+ uint size_extrafield_local,
+ IntPtr extrafield_global,
+ uint size_extrafield_global,
+ string comment,
+ int method,
+ int level);
}
}
string[] Files {
get {
if (files == null)
- files = NativeUnzip.GetFiles (Handle);
+ files = NativeVersion.Use32Bit ? NativeUnzip.GetFiles32 (Handle) : NativeUnzip.GetFiles64 (Handle);
return files;
}
}
public UnzipArchive (Stream stream, bool ownsStream)
{
Stream = new ZipStream (stream, ownsStream);
- Handle = NativeUnzip.OpenArchive (Stream.IOFunctions);
+ Handle = NativeVersion.Use32Bit ? NativeUnzip.OpenArchive32 (Stream.IOFunctions32) : NativeUnzip.OpenArchive64 (Stream.IOFunctions64);
}
public void Dispose ()
namespace zipsharp
{
[StructLayout (LayoutKind.Sequential)]
- struct UnzipFileInfo
+ struct UnzipFileInfo32
{
- IntPtr version; /* version made by 2 bytes */
- IntPtr version_needed; /* version needed to extract 2 bytes */
- IntPtr flag; /* general purpose bit flag 2 bytes */
- IntPtr compression_method; /* compression method 2 bytes */
- IntPtr dosDate; /* last mod file date in Dos fmt 4 bytes */
- IntPtr crc; /* crc-32 4 bytes */
- IntPtr compressed_size; /* compressed size 4 bytes */
- IntPtr uncompressed_size; /* uncompressed size 4 bytes */
- IntPtr size_filename; /* filename length 2 bytes */
- IntPtr size_file_extra; /* extra field length 2 bytes */
- IntPtr size_file_comment; /* file comment length 2 bytes */
+ public uint version; /* version made by 2 bytes */
+ public uint version_needed; /* version needed to extract 2 bytes */
+ public uint flag; /* general purpose bit flag 2 bytes */
+ public uint compression_method; /* compression method 2 bytes */
+ public uint dosDate; /* last mod file date in Dos fmt 4 bytes */
+ public uint crc; /* crc-32 4 bytes */
+ public uint compressed_size; /* compressed size 4 bytes */
+ public uint uncompressed_size; /* uncompressed size 4 bytes */
+ public uint size_filename; /* filename length 2 bytes */
+ public uint size_file_extra; /* extra field length 2 bytes */
+ public uint size_file_comment; /* file comment length 2 bytes */
- IntPtr disk_num_start; /* disk number start 2 bytes */
- IntPtr internal_fa; /* internal file attributes 2 bytes */
- IntPtr external_fa; /* external file attributes 4 bytes */
+ public uint disk_num_start; /* disk number start 2 bytes */
+ public uint internal_fa; /* internal file attributes 2 bytes */
+ public uint external_fa; /* external file attributes 4 bytes */
ZipTime tmu_date;
-
- public ulong VersionNeeded {
- get { return (ulong)version_needed.ToInt64 (); }
- set { version_needed = new IntPtr ((int)value); }
- }
-
- public ulong Version {
- get { return (ulong)version.ToInt64 (); }
- set { version = new IntPtr ((int)value); }
- }
-
- public ulong UncompressedSize {
- get { return (ulong)uncompressed_size.ToInt64 (); }
- set { uncompressed_size = new IntPtr ((int)value); }
- }
-
- public ZipTime TmuDate {
- get { return tmu_date; }
- set { tmu_date = value; }
- }
-
- public ulong SizeFilename {
- get { return (ulong)size_filename.ToInt64 (); }
- set { size_filename = new IntPtr ((int)value); }
- }
-
- public ulong SizeFileExtra {
- get { return (ulong)size_file_extra.ToInt64 (); }
- set { size_file_extra = new IntPtr ((int)value); }
- }
-
- public ulong SizeFileComment {
- get {
- return (ulong)size_file_comment.ToInt64 ();
- }
- set {
- size_file_comment = new IntPtr ((int)value);
- }
- }
-
- public ulong InternalFa {
- get { return (ulong)internal_fa.ToInt64 (); }
- set { internal_fa = new IntPtr ((int)value); }
- }
-
- public ulong Flag {
- get { return (ulong)flag.ToInt64 (); }
- set { flag = new IntPtr ((int)value); }
- }
-
- public ulong ExternalFa {
- get { return (ulong)external_fa.ToInt64 (); }
- set { external_fa = new IntPtr ((int)value); }
- }
-
- public ulong DosDate {
- get { return (ulong)dosDate.ToInt64 (); }
- set { dosDate = new IntPtr ((int)value); }
- }
-
- public ulong DiskNumStart {
- get { return (ulong)disk_num_start.ToInt64 (); }
- set { disk_num_start = new IntPtr ((int)value); }
- }
-
- public ulong Crc {
- get { return (ulong)crc.ToInt64 (); }
- set { crc = new IntPtr ((int)value); }
- }
-
- public ulong CompressionMethod {
- get { return (ulong)compression_method.ToInt64 (); }
- set { compression_method = new IntPtr ((int)value); }
- }
-
- public ulong CompressedSize {
- get { return (ulong)compressed_size.ToInt64 (); }
- set { compressed_size = new IntPtr ((int)value); }
- }
+ }
+
+ [StructLayout (LayoutKind.Sequential)]
+ struct UnzipFileInfo64
+ {
+ public ulong version; /* version made by 2 bytes */
+ public ulong version_needed; /* version needed to extract 2 bytes */
+ public ulong flag; /* general purpose bit flag 2 bytes */
+ public ulong compression_method; /* compression method 2 bytes */
+ public ulong dosDate; /* last mod file date in Dos fmt 4 bytes */
+ public ulong crc; /* crc-32 4 bytes */
+ public ulong compressed_size; /* compressed size 4 bytes */
+ public ulong uncompressed_size; /* uncompressed size 4 bytes */
+ public ulong size_filename; /* filename length 2 bytes */
+ public ulong size_file_extra; /* extra field length 2 bytes */
+ public ulong size_file_comment; /* file comment length 2 bytes */
+
+ public ulong disk_num_start; /* disk number start 2 bytes */
+ public ulong internal_fa; /* internal file attributes 2 bytes */
+ public ulong external_fa; /* external file attributes 4 bytes */
+
+ ZipTime tmu_date;
}
}
Archive = archive;
Archive.FileActive = true;
CompressionLevel = compressionLevel;
- length = NativeUnzip.CurrentFileLength (Archive.Handle);
+ length = NativeVersion.Use32Bit ? NativeUnzip.CurrentFileLength32 (Archive.Handle) : NativeUnzip.CurrentFileLength64 (Archive.Handle);
}
public override void Close()
public ZipArchive (Stream stream, Append append, bool ownsStream)
{
Stream = new ZipStream (stream, ownsStream);
- Handle = NativeZip.OpenArchive (Stream.IOFunctions, append);
+ Handle = NativeVersion.Use32Bit ? NativeZip.OpenArchive32 (Stream.IOFunctions32, append) : NativeZip.OpenArchive64 (Stream.IOFunctions64, append);
}
{
if (FileActive)
throw new InvalidOperationException ("A file is already open");
-
- NativeZip.OpenFile (Handle, filename, ConvertCompression (option));
+
+ if (NativeVersion.Use32Bit)
+ NativeZip.OpenFile32 (Handle, filename, ConvertCompression (option));
+ else
+ NativeZip.OpenFile64 (Handle, filename, ConvertCompression (option));
return new ZipWriteStream (this);
}
namespace zipsharp
{
[StructLayoutAttribute (LayoutKind.Sequential)]
- struct ZipFileInfo
+ struct ZipFileInfo32
{
ZipTime date;
- IntPtr dosDate;
- IntPtr internalFileAttributes;
- IntPtr externalFileAttributes;
+ uint dosDate;
+ uint internalFileAttributes;
+ uint externalFileAttributes;
- public DateTime FileTime
+ public ZipFileInfo32 (DateTime fileTime)
{
- get { return date.Date; }
+ date = new ZipTime (fileTime);
+ dosDate = 0;
+ internalFileAttributes = 0;
+ externalFileAttributes = 0;
}
+ }
- public long DosDate
- {
- get { return dosDate.ToInt64 (); }
- }
-
- internal long InternalFileAttributes
- {
- get { return internalFileAttributes.ToInt64 (); }
- }
+ [StructLayoutAttribute (LayoutKind.Sequential)]
+ struct ZipFileInfo64
+ {
+ ZipTime date;
+ ulong dosDate;
+ ulong internalFileAttributes;
+ ulong externalFileAttributes;
- internal long ExternalFileAttributes
- {
- get { return externalFileAttributes.ToInt64 (); }
- }
-
- public ZipFileInfo (DateTime fileTime)
+ public ZipFileInfo64 (DateTime fileTime)
{
date = new ZipTime (fileTime);
- dosDate = IntPtr.Zero;
- internalFileAttributes = IntPtr.Zero;
- externalFileAttributes = IntPtr.Zero;
+ dosDate = 0;
+ internalFileAttributes = 0;
+ externalFileAttributes = 0;
}
-
}
}
get; set;
}
- public ZlibFileFuncDef IOFunctions {
+ public ZlibFileFuncDef32 IOFunctions32 {
+ get; set;
+ }
+
+ public ZlibFileFuncDef64 IOFunctions64 {
get; set;
}
DataStream = dataStream;
OwnsStream = ownsStream;
- ZlibFileFuncDef f = new ZlibFileFuncDef();
-
- f.opaque = IntPtr.Zero;
- f.zclose_file = CloseFile_Native;
- f.zerror_file = TestError_Native;
- f.zopen_file = OpenFile_Native;
- f.zread_file = ReadFile_Native;
- f.zseek_file = SeekFile_Native;
- f.ztell_file = TellFile_Native;
- f.zwrite_file = WriteFile_Native;
-
- IOFunctions = f;
+ ZlibFileFuncDef32 f32 = new ZlibFileFuncDef32 ();
+ f32.opaque = IntPtr.Zero;
+ f32.zclose_file = CloseFile_Native;
+ f32.zerror_file = TestError_Native;
+ f32.zopen_file = OpenFile_Native;
+ f32.zread_file = ReadFile_Native32;
+ f32.zseek_file = SeekFile_Native32;
+ f32.ztell_file = TellFile_Native32;
+ f32.zwrite_file = WriteFile_Native32;
+ IOFunctions32 = f32;
+
+ ZlibFileFuncDef64 f64 = new ZlibFileFuncDef64 ();
+ f64.opaque = IntPtr.Zero;
+ f64.zclose_file = CloseFile_Native;
+ f64.zerror_file = TestError_Native;
+ f64.zopen_file = OpenFile_Native;
+ f64.zread_file = ReadFile_Native64;
+ f64.zseek_file = SeekFile_Native64;
+ f64.ztell_file = TellFile_Native64;
+ f64.zwrite_file = WriteFile_Native64;
+ IOFunctions64 = f64;
}
protected override void Dispose(bool disposing)
return new IntPtr (1);
}
- unsafe IntPtr ReadFile_Native (IntPtr opaque, IntPtr stream, IntPtr buffer, IntPtr size)
+ unsafe uint ReadFile_Native32 (IntPtr opaque, IntPtr stream, IntPtr buffer, uint size)
{
- int count = size.ToInt32 ();
+ return (uint) ReadFile_Native64 (opaque, stream, buffer, size);
+ }
+
+ unsafe ulong ReadFile_Native64 (IntPtr opaque, IntPtr stream, IntPtr buffer, ulong size)
+ {
+ int count = (int) size;
byte[] b = new byte[count];
int read;
read = -1;
}
- return new IntPtr (read);
+ return (ulong) read;
}
- IntPtr SeekFile_Native (IntPtr opaque, IntPtr stream, IntPtr offset, int origin)
+ int SeekFile_Native32 (IntPtr opaque, IntPtr stream, uint offset, int origin)
+ {
+ return (int) SeekFile_Native64 (opaque, stream, offset, origin);
+ }
+
+ long SeekFile_Native64 (IntPtr opaque, IntPtr stream, ulong offset, int origin)
{
SeekOrigin seek;
if (origin == ZipStream.ZLIB_FILEFUNC_SEEK_CUR)
else if (origin == ZLIB_FILEFUNC_SEEK_SET)
seek = SeekOrigin.Begin;
else
- return new IntPtr (-1);
+ return -1;
- Seek (offset.ToInt64 (), seek);
+ Seek ((long) offset, seek);
- return new IntPtr (0);
+ return 0;
}
- IntPtr TellFile_Native (IntPtr opaque, IntPtr stream)
+ int TellFile_Native32 (IntPtr opaque, IntPtr stream)
{
- if (IntPtr.Size == 4)
- return new IntPtr ((int)Position);
- else if (IntPtr.Size == 8)
- return new IntPtr (Position);
- else
- return new IntPtr (-1);
+ return (int) TellFile_Native64 (opaque, stream);
+ }
+
+ long TellFile_Native64 (IntPtr opaque, IntPtr stream)
+ {
+ return Position;
}
int TestError_Native (IntPtr opaque, IntPtr stream)
return 0;
}
- unsafe IntPtr WriteFile_Native (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ IntPtr size)
+ unsafe uint WriteFile_Native32 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ uint size)
+ {
+ return (uint) WriteFile_Native64 (opaque, stream, buffer, size);
+ }
+
+ unsafe ulong WriteFile_Native64 (IntPtr opaque, IntPtr stream, IntPtr buffer, /* ulong */ ulong size)
{
- int count = size.ToInt32 ();
+ int count = (int) size;
byte[] b = new byte[count];
byte* ptrBuffer = (byte*) buffer.ToPointer ();
}
- return new IntPtr (count);
+ return (ulong) count;
}
}
}
ReadZStream\r
WriteZStream\r
Flush\r
-\r
+zipWriteInFileInZip\r
+zipCloseFileInZip\r
+zipOpen2\r
+zipClose\r
+zipOpenNewFileInZip\r
+unzOpen2\r
+unzCloseCurrentFile\r
+unztell\r
+unzGoToFirstFile\r
+unzGoToNextFile\r
+unzLocateFile\r
+unzOpenCurrentFile2\r
+unzGetCurrentFileInfo\r
+unzReadCurrentFile\r
+unzClose\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>_DEBUG;__i386__;TARGET_X86;_WIN32_WINNT=0x0600;WIN32;_WIN32;__WIN32__;_WINDOWS;WINDOWS;HOST_WIN32;TARGET_WIN32;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<WarningLevel>Level3</WarningLevel>\r
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
<CompileAs>CompileAsC</CompileAs>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_DIR)/support;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
</ClCompile>\r
<Link>\r
<AdditionalDependencies>eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
</Midl>\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>_DEBUG;__x86_64__;_WIN32_WINNT=0x0600;WIN64;_WIN64;WIN32;_WIN32;__WIN32__;_WINDOWS;WINDOWS;HOST_WIN32;TARGET_WIN32;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<WarningLevel>Level3</WarningLevel>\r
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
<CompileAs>CompileAsC</CompileAs>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_DIR)/support;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
</ClCompile>\r
<Link>\r
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>NDEBUG;__i386__;TARGET_X86;i386;_WIN32_WINNT=0x0600;WIN32;_WIN32;__WIN32__;_WINDOWS;WINDOWS;HOST_WIN32;TARGET_WIN32;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
<WarningLevel>Level3</WarningLevel>\r
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
<CompileAs>CompileAsC</CompileAs>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_DIR)/support;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
</ClCompile>\r
<Link>\r
<AdditionalDependencies>eglib.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
</Midl>\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>NDEBUG;__x86_64__;_WIN32_WINNT=0x0600;WIN64;_WIN64;WIN32;_WIN32;__WIN32__;_WINDOWS;WINDOWS;HOST_WIN32;TARGET_WIN32;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
<WarningLevel>Level3</WarningLevel>\r
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r
<CompileAs>CompileAsC</CompileAs>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_DIR)/support;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
</ClCompile>\r
<Link>\r
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r
<ClCompile Include="..\support\inflate.c" />\r
<ClCompile Include="..\support\inftrees.c" />\r
<ClCompile Include="..\support\map.c" />\r
+ <ClCompile Include="..\support\minizip\ioapi.c" />\r
+ <ClCompile Include="..\support\minizip\iowin32.c" />\r
+ <ClCompile Include="..\support\minizip\minizip.c" />\r
+ <ClCompile Include="..\support\minizip\unzip.c" />\r
+ <ClCompile Include="..\support\minizip\zip.c" />\r
<ClCompile Include="..\support\signal.c" />\r
<ClCompile Include="..\support\stdio.c" />\r
<ClCompile Include="..\support\stdlib.c" />\r
<ClInclude Include="..\support\inflate.h" />\r
<ClInclude Include="..\support\inftrees.h" />\r
<ClInclude Include="..\support\map.h" />\r
+ <ClInclude Include="..\support\minizip\crypt.h" />\r
+ <ClInclude Include="..\support\minizip\ioapi.h" />\r
+ <ClInclude Include="..\support\minizip\iowin32.h" />\r
+ <ClInclude Include="..\support\minizip\unzip.h" />\r
+ <ClInclude Include="..\support\minizip\zip.h" />\r
<ClInclude Include="..\support\mph.h" />\r
<ClInclude Include="..\support\trees.h" />\r
<ClInclude Include="..\support\zconf.h" />\r
+ <ClInclude Include="..\support\zlib.h" />\r
<ClInclude Include="..\support\zutil.h" />\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="..\support\zutil.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\support\minizip\iowin32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\support\minizip\minizip.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\support\minizip\unzip.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\support\minizip\zip.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\support\minizip\ioapi.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\support\crc32.h">\r
<ClInclude Include="..\support\zutil.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
+ <ClInclude Include="..\support\minizip\crypt.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\support\minizip\unzip.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\support\minizip\iowin32.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\support\minizip\zip.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\support\zlib.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="..\support\minizip\ioapi.h">\r
+ <Filter>Header Files</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<Filter Include="Header Files">\r