1 // ZipArchive.cs created with MonoDevelop
2 // User: alan at 16:31 20/10/2008
4 // To change standard headers go to Edit->Preferences->Coding->Standard Headers
9 using System
.IO
.Packaging
;
13 class ZipArchive
: IDisposable
15 internal bool FileActive { get; set; }
16 internal ZipHandle Handle { get; private set; }
17 ZipStream Stream { get; set; }
19 public ZipArchive (string filename
, Append append
)
20 : this (File
.Open (filename
, FileMode
.OpenOrCreate
), append
)
25 public ZipArchive (Stream stream
, Append append
)
26 : this (stream
, append
, false)
31 public ZipArchive (Stream stream
, Append append
, bool ownsStream
)
33 Stream
= new ZipStream (stream
, ownsStream
);
34 Handle
= NativeZip
.OpenArchive (Stream
.IOFunctions
, append
);
38 static int ConvertCompression (System
.IO
.Packaging
.CompressionOption option
)
42 case CompressionOption
.SuperFast
:
45 case CompressionOption
.Fast
:
48 case CompressionOption
.Normal
:
51 case CompressionOption
.Maximum
:
60 public Stream
GetStream (string filename
, System
.IO
.Packaging
.CompressionOption option
)
63 throw new InvalidOperationException ("A file is already open");
65 NativeZip
.OpenFile (Handle
, filename
, ConvertCompression (option
));
66 return new ZipWriteStream (this);
69 public void Dispose ()
71 NativeZip
.CloseArchive (Handle
);