Exemple #1
0
        /// <summary>
        /// Set the data from the raw values provided.
        /// </summary>
        /// <param name="data">The raw data to extract values from.</param>
        /// <param name="index">The index to start extracting values from.</param>
        /// <param name="count">The number of bytes available.</param>
        public void SetData(byte[] data, int index, int count)
        {
            using (MemoryStream ms = new MemoryStream(data, index, count, false))
                using (ZipHelperStream helperStream = new ZipHelperStream(ms)) {
                    // bit 0           if set, modification time is present
                    // bit 1           if set, access time is present
                    // bit 2           if set, creation time is present

                    _flags = (Flags)helperStream.ReadByte();
                    if (((_flags & Flags.ModificationTime) != 0))
                    {
                        int iTime = helperStream.ReadLEInt();

                        _modificationTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) +
                                            new TimeSpan(0, 0, 0, iTime, 0);

                        // Central-header version is truncated after modification time
                        if (count <= 5)
                        {
                            return;
                        }
                    }

                    if ((_flags & Flags.AccessTime) != 0)
                    {
                        int iTime = helperStream.ReadLEInt();

                        _lastAccessTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) +
                                          new TimeSpan(0, 0, 0, iTime, 0);
                    }

                    if ((_flags & Flags.CreateTime) != 0)
                    {
                        int iTime = helperStream.ReadLEInt();

                        _createTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) +
                                      new TimeSpan(0, 0, 0, iTime, 0);
                    }
                }
        }