using System;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
class MainClass
{
public static void Main(string[] args)
{
string[] filenames = Directory.GetFiles(args[0]);
byte[] buffer = new byte[4096];
using ( ZipOutputStream s = new ZipOutputStream(File.Create(args[1])) ) {
s.SetLevel(9); // 0 - store only to 9 - means best compression
foreach (string file in filenames) {
ZipEntry entry = new ZipEntry(file);
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file)) {
StreamUtils.Copy(fs, s, buffer);
}
}
}
}
}
def.deflate()
until all bytes from the input buffers
are processed.
using System;
using System.IO;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Core;
class MainClass
{
public static void Main(string[] args)
{
using (Stream s = new GZipOutputStream(File.Create(args[0] + ".gz")))
using (FileStream fs = File.OpenRead(args[0])) {
byte[] writeData = new byte[4096];
Streamutils.Copy(s, fs, writeData);
}
}
}
}
using System;
using System.Text;
using System.Collections;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
class MainClass
{
static public void Main(string[] args)
{
using (ZipFile zFile = new ZipFile(args[0])) {
Console.WriteLine("Listing of : " + zFile.Name);
Console.WriteLine("");
Console.WriteLine("Raw Size Size Date Time Name");
Console.WriteLine("-------- -------- -------- ------ ---------");
foreach (ZipEntry e in zFile) {
if ( e.IsFile ) {
DateTime d = e.DateTime;
Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize,
d.ToString("dd-MM-yy"), d.ToString("HH:mm"),
e.Name);
}
}
}
}
}
getValue
. The complete checksum object can also be reset
so it can be used again with new data.
TarEntries that are created from the header bytes read from an archive are instantiated with the TarEntry( byte[] ) constructor. These entries will be used when extracting from or listing the contents of an archive. These entries have their header filled in using the header bytes. They also set the File to null, since they reference an archive entry not a file.
TarEntries that are created from files that are to be written into an archive are instantiated with the CreateEntryFromFile(string) pseudo constructor. These entries have their header filled in using the File's information. They also keep a reference to the File for convenience when writing entries.
Finally, TarEntries can be constructed from nothing but a name. This allows the programmer to construct the entry by hand, for instance when only an InputStream is available for writing to the archive, and the header information is constructed from other information. In this case the header fields are set to defaults and the File is set to null.
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.GZip;
class MainClass
{
public static void Main(string[] args)
{
using (Stream inStream = new GZipInputStream(File.OpenRead(args[0])))
using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) {
byte[] buffer = new byte[4096];
StreamUtils.Copy(inStream, outStream, buffer);
}
}
}
using System;
using System.Text;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
class MainClass
{
public static void Main(string[] args)
{
using ( ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]))) {
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null) {
int size = 2048;
byte[] data = new byte[2048];
Console.Write("Show contents (y/n) ?");
if (Console.ReadLine() == "y") {
while (true) {
size = s.Read(data, 0, data.Length);
if (size > 0) {
Console.Write(new ASCIIEncoding().GetString(data, 0, size));
} else {
break;
}
}
}
}
}
}
}
NeedsInput()
returns true
strstart + MAX_MATCH <= window.length.
prev[index & WMASK]
points to the previous index that has the
same hash code as the string starting at index. This way
entries with the same hash code are in a linked list.
Note that the array should really be unsigned short, so you need
to and the values with 0xffff.
You should never have a need to access this class directly. TarBuffers are created by Tar IO Streams.
setInput(input, 0, input.length)
.
setDictionary(dict, 0, dict.Length)
.
Read()
public Inflater(bool noHeader)
passing true
if there is no Zlib header information
The usage is as following. First you have to set some input with
SetInput()
, then Inflate() it. If inflate doesn't
inflate any bytes there may be three reasons:
SetInput()
.
NOTE: IsNeedingInput() also returns true when, the stream is finished.
SetDictionary()
.