示例#1
0
        public static int ReadHeaderInternal(IntPtr arcData, IntPtr headerData, HeaderDataMode mode)
        {
            PackerResult result = PackerResult.EndArchive;

            callSignature = String.Format("ReadHeader ({0})", arcData.ToString());
            try {
                object o = TcHandles.GetObject(arcData);
                if (o == null)
                {
                    return((int)PackerResult.ErrorOpen);
                }
                HeaderData header;
                result = Plugin.ReadHeader(ref o, out header);
                if (result == PackerResult.OK)
                {
                    header.CopyTo(headerData, mode);
                    TcHandles.UpdateHandle(arcData, o);
                }

                // !!! may produce much trace info !!!
                TraceCall(TraceLevel.Verbose, String.Format("{0} ({1})",
                                                            result.ToString(), (result == PackerResult.OK) ? header.FileName : null));
            } catch (Exception ex) {
                ProcessException(ex);
            }
            return((int)result);
        }
示例#2
0
        public static int ReadHeaderInternal(IntPtr arcData, IntPtr headerData, HeaderDataMode mode)
        {
            var result = PackerResult.EndArchive;

            _callSignature = $"ReadHeader ({arcData.ToString()})";
            try {
                var o = TcHandles.GetObject(arcData);
                if (o == null)
                {
                    return((int)PackerResult.ErrorOpen);
                }

                result = Plugin.ReadHeader(ref o, out var header);
                if (result == PackerResult.OK)
                {
                    header.CopyTo(headerData, mode);
                    TcHandles.UpdateHandle(arcData, o);
                }

                // !!! may produce much trace info !!!
                TraceCall(TraceLevel.Verbose, $"{result.ToString()} ({((result == PackerResult.OK) ? header.FileName : null)})");
            }
            catch (Exception ex) {
                ProcessException(ex);
            }

            return((int)result);
        }
示例#3
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);
                }
            }
        }