ICSharpCode.SharpZipLib.Zip.ZipExtraData.GetData C# (CSharp) Method

GetData() private method

Get the tagged data for a tag.
private GetData ( short tag ) : ITaggedData
tag short The tag to search for.
return ITaggedData
        private ITaggedData GetData(short tag) {
            ITaggedData result=null;
            if (Find(tag)) {
                result=Create(tag, _data, _readValueStart, _readValueLength);
            }
            return result;
        }

Usage Example

Esempio n. 1
0
        private DateTime GetDateTime(ZipExtraData extraData)
        {
            // Check for NT timestamp
            // NOTE: Disable by default to match behavior of InfoZIP
#if RESPECT_NT_TIMESTAMP
            NTTaggedData ntData = extraData.GetData <NTTaggedData>();
            if (ntData != null)
            {
                return(ntData.LastModificationTime);
            }
#endif

            // Check for Unix timestamp
            ExtendedUnixData unixData = extraData.GetData <ExtendedUnixData>();
            if (unixData != null &&
                // Only apply modification time, but require all other values to be present
                // This is done to match InfoZIP's behaviour
                ((unixData.Include & ExtendedUnixData.Flags.ModificationTime) != 0) &&
                ((unixData.Include & ExtendedUnixData.Flags.AccessTime) != 0) &&
                ((unixData.Include & ExtendedUnixData.Flags.CreateTime) != 0))
            {
                return(unixData.ModificationTime);
            }

            // Fall back to DOS time
            uint sec  = Math.Min(59, 2 * (dosTime & 0x1f));
            uint min  = Math.Min(59, (dosTime >> 5) & 0x3f);
            uint hrs  = Math.Min(23, (dosTime >> 11) & 0x1f);
            uint mon  = Math.Max(1, Math.Min(12, ((dosTime >> 21) & 0xf)));
            uint year = ((dosTime >> 25) & 0x7f) + 1980;
            int  day  = Math.Max(1, Math.Min(DateTime.DaysInMonth((int)year, (int)mon), (int)((dosTime >> 16) & 0x1f)));
            return(new DateTime((int)year, (int)mon, day, (int)hrs, (int)min, (int)sec, DateTimeKind.Utc));
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipExtraData::GetData