Esempio 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);
                }
            }
        }
Esempio n. 2
0
 public void CopyTo(IntPtr ptr, bool isUnicode)
 {
     if (ptr != IntPtr.Zero)
     {
         if (isUnicode)
         {
             var data = new TcFindDataW {
                 FileAttributes    = (int)Attributes,
                 CreationTime      = TcUtils.GetFileTime(CreationTime),
                 LastAccessTime    = TcUtils.GetFileTime(LastAccessTime),
                 LastWriteTime     = TcUtils.GetFileTime(LastWriteTime),
                 FileSizeHigh      = TcUtils.GetUHigh(FileSize),
                 FileSizeLow       = TcUtils.GetULow(FileSize),
                 Reserved0         = Reserved0,
                 Reserved1         = Reserved1,
                 FileName          = FileName,
                 AlternateFileName = string.Empty
             };
             Marshal.StructureToPtr(data, ptr, false);
         }
         else
         {
             var data = new TcFindData {
                 FileAttributes    = (int)Attributes,
                 CreationTime      = TcUtils.GetFileTime(CreationTime),
                 LastAccessTime    = TcUtils.GetFileTime(LastAccessTime),
                 LastWriteTime     = TcUtils.GetFileTime(LastWriteTime),
                 FileSizeHigh      = TcUtils.GetUHigh(FileSize),
                 FileSizeLow       = TcUtils.GetULow(FileSize),
                 Reserved0         = Reserved0,
                 Reserved1         = Reserved1,
                 FileName          = FileName,
                 AlternateFileName = string.Empty
             };
             Marshal.StructureToPtr(data, ptr, false);
         }
     }
 }