Beispiel #1
0
        public bool ReadHeader()
        {
            if (this.archiveHandle == IntPtr.Zero)
            {
                throw new IOException("Archive is not open.");
            }
            this.header = new RARHeaderDataEx();
            this.header.Initialize();
            this.currentFile = null;
            switch (RARReadHeaderEx(this.archiveHandle, ref this.header))
            {
            case 10:
                return(false);

            case 12:
                throw new IOException("Archive data is corrupt.");
            }
            if (((this.header.Flags & 1) != 0) && (this.currentFile != null))
            {
                this.currentFile.ContinuedFromPrevious = true;
            }
            else
            {
                this.currentFile          = new RARFileInfo();
                this.currentFile.FileName = this.header.FileNameW.ToString();
                if ((this.header.Flags & 2) != 0)
                {
                    this.currentFile.ContinuedOnNext = true;
                }
                if (this.header.PackSizeHigh != 0)
                {
                    this.currentFile.PackedSize = (this.header.PackSizeHigh * 0x100000000L) + this.header.PackSize;
                }
                else
                {
                    this.currentFile.PackedSize = this.header.PackSize;
                }
                if (this.header.UnpSizeHigh != 0)
                {
                    this.currentFile.UnpackedSize = (this.header.UnpSizeHigh * 0x100000000L) + this.header.UnpSize;
                }
                else
                {
                    this.currentFile.UnpackedSize = this.header.UnpSize;
                }
                this.currentFile.HostOS          = (int)this.header.HostOS;
                this.currentFile.FileCRC         = this.header.FileCRC;
                this.currentFile.FileTime        = this.FromMSDOSTime(this.header.FileTime);
                this.currentFile.VersionToUnpack = (int)this.header.UnpVer;
                this.currentFile.Method          = (int)this.header.Method;
                this.currentFile.FileAttributes  = (int)this.header.FileAttr;
                this.currentFile.BytesExtracted  = 0L;
                if ((this.header.Flags & 0xe0) == 0xe0)
                {
                    this.currentFile.IsDirectory = true;
                }
                this.OnNewFile();
            }
            return(true);
        }
 public NewFileEventArgs(RARFileInfo fileInfo)
 {
     this.fileInfo = fileInfo;
 }