Ejemplo n.º 1
0
        //public int UnpVer { get; set; }
        //public int Method { get; set; }

        //   may be used in the future
        //public string CmtBuf { get; set; }
        //public int CmtBufSize { get; set; }
        //public int CmtSize { get; set; }
        //public int CmtState { get; set; }
        //public string Reserved { get; set; }

        #endregion Properties

        public void CopyTo(IntPtr ptr, HeaderDataMode mode)
        {
            if (ptr != IntPtr.Zero)
            {
                if (mode == HeaderDataMode.Ansi)
                {
                    var data = new TcHeaderData {
                        ArchiveName = ArchiveName,
                        FileName    = FileName,
                        FileAttr    = ((int)FileAttributes) & AllowedPackerAttributes,
                        FileCRC     = FileCRC,
                        FileTime    = TcUtils.GetArchiveHeaderTime(FileTime),
                        PackSize    = (int)PackedSize,
                        UnpSize     = (int)UnpackedSize
                    };
                    Marshal.StructureToPtr(data, ptr, false);
                }
                else if (mode == HeaderDataMode.ExAnsi)
                {
                    var data = new TcHeaderDataEx {
                        ArchiveName  = ArchiveName,
                        FileName     = FileName,
                        FileAttr     = ((int)FileAttributes) & AllowedPackerAttributes,
                        FileCRC      = FileCRC,
                        FileTime     = TcUtils.GetArchiveHeaderTime(FileTime),
                        PackSizeHigh = TcUtils.GetUHigh(PackedSize),
                        PackSizeLow  = TcUtils.GetULow(PackedSize),
                        UnpSizeHigh  = TcUtils.GetUHigh(UnpackedSize),
                        UnpSizeLow   = TcUtils.GetULow(UnpackedSize)
                    };
                    Marshal.StructureToPtr(data, ptr, false);
                }
                else if (mode == HeaderDataMode.ExUnicode)
                {
                    var data = new TcHeaderDataExW {
                        ArchiveName  = ArchiveName,
                        FileName     = FileName,
                        FileAttr     = ((int)FileAttributes) & AllowedPackerAttributes,
                        FileCRC      = FileCRC,
                        FileTime     = TcUtils.GetArchiveHeaderTime(FileTime),
                        PackSizeHigh = TcUtils.GetUHigh(PackedSize),
                        PackSizeLow  = TcUtils.GetULow(PackedSize),
                        UnpSizeHigh  = TcUtils.GetUHigh(UnpackedSize),
                        UnpSizeLow   = TcUtils.GetULow(UnpackedSize)
                    };
                    Marshal.StructureToPtr(data, ptr, false);
                }
            }
        }