예제 #1
0
 public UnzipReadStream(UnzipArchive archive, CompressionOption compressionLevel)
 {
     Archive            = archive;
     Archive.FileActive = true;
     CompressionLevel   = compressionLevel;
     length             = NativeUnzip.CurrentFileLength(Archive.Handle);
 }
예제 #2
0
 static void GoToFirstFile(UnzipHandle handle)
 {
     if (NativeUnzip.unzGoToFirstFile(handle) != 0)
     {
         throw new Exception("Zip file is invalid");
     }
 }
예제 #3
0
        public Stream GetStream(string name)
        {
            foreach (string file in Files)
            {
                if (name.Equals(file, StringComparison.OrdinalIgnoreCase))
                {
                    System.IO.Packaging.CompressionOption option;
                    NativeUnzip.OpenFile(Handle, name, out option);
                    return(new UnzipReadStream(this, option));
                }
            }

            throw new Exception("The file doesn't exist in the zip archive");
        }
예제 #4
0
        private static string[] GetFiles(UnzipHandle handle, Func <UnzipHandle, string> getCurrentFileName)
        {
            GoToFirstFile(handle);
            var    files = new List <string> ();
            string name;

            while ((name = getCurrentFileName(handle)) != null)
            {
                files.Add(name);
                if (!NativeUnzip.GoToNextFile(handle))
                {
                    break;
                }
            }

            return(files.ToArray());
        }
예제 #5
0
        public static string[] GetFiles(UnzipHandle handle)
        {
            List <string> files = new List <string> ();

            GoToFirstFile(handle);

            string name;

            while ((name = GetCurrentFileName(handle)) != null)
            {
                files.Add(name);
                if (!NativeUnzip.GoToNextFile(handle))
                {
                    break;
                }
            }

            return(files.ToArray());
        }
예제 #6
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     return(NativeUnzip.Read(Archive.Handle, buffer, offset, count));
 }
예제 #7
0
 public override void Close()
 {
     Archive.FileActive = false;
     NativeUnzip.CloseCurrentFile(Archive.Handle);
 }
예제 #8
0
 public void Dispose()
 {
     NativeUnzip.CloseArchive(Handle);
     Stream.Close();
 }
예제 #9
0
 public UnzipArchive(Stream stream, bool ownsStream)
 {
     Stream = new ZipStream(stream, ownsStream);
     Handle = NativeUnzip.OpenArchive(Stream.IOFunctions);
 }
예제 #10
0
 public UnzipArchive(Stream stream, bool ownsStream)
 {
     Stream = new ZipStream(stream, ownsStream);
     Handle = NativeVersion.Use32Bit ? NativeUnzip.OpenArchive32(Stream.IOFunctions32) : NativeUnzip.OpenArchive64(Stream.IOFunctions64);
 }
예제 #11
0
 protected override bool ReleaseHandle()
 {
     NativeUnzip.CloseArchive(this);
     return(true);
 }