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)); }
private static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData result = null; switch (tag) { case 0x000A: result = new NTTaggedData(); break; case 0x5455: result = new ExtendedUnixData(); break; default: result = new RawTaggedData(tag); break; } result.SetData(data, offset, count); return(result); }
private static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData taggedData = null; switch (tag) { case 10: taggedData = new NTTaggedData(); break; case 21589: taggedData = new ExtendedUnixData(); break; default: taggedData = new RawTaggedData(tag); break; } taggedData.SetData(data, offset, count); return(taggedData); }
private static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData data2 = null; switch (tag) { case 10: data2 = new NTTaggedData(); break; case 0x5455: data2 = new ExtendedUnixData(); break; default: data2 = new RawTaggedData(tag); break; } data2.SetData(data, offset, count); return(data2); }
private static 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 && unixData.Include.HasFlag(ExtendedUnixData.Flags.ModificationTime)) { return(unixData.ModificationTime); } return(null); }
private ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData data2 = null; switch (tag) { case 10: data2 = new NTTaggedData(); break; case 0x5455: data2 = new ExtendedUnixData(); break; default: data2 = new RawTaggedData(tag); break; } data2.SetData(this.data_, this.readValueStart_, this.readValueLength_); return(data2); }
private static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData taggedData; if (tag != 10) { if (tag != 21589) { taggedData = new RawTaggedData(tag); } else { taggedData = new ExtendedUnixData(); } } else { taggedData = new NTTaggedData(); } taggedData.SetData(data, offset, count); return(taggedData); }
static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData result = null; switch ( tag ) { case 0x000A: result = new NTTaggedData(); break; case 0x5455: result = new ExtendedUnixData(); break; default: result = new RawTaggedData(tag); break; } result.SetData(data, offset, count); return result; }
public void TaggedDataHandling() { NTTaggedData tagData = new NTTaggedData(); DateTime modTime = tagData.LastModificationTime; byte[] rawData = tagData.GetData(); tagData.LastModificationTime = tagData.LastModificationTime + TimeSpan.FromSeconds(40); Assert.AreNotEqual(tagData.LastModificationTime, modTime); tagData.SetData(rawData, 0, rawData.Length); Assert.AreEqual(10, tagData.TagID, "TagID mismatch"); Assert.AreEqual(modTime, tagData.LastModificationTime, "NT Mod time incorrect"); tagData.CreateTime=DateTime.FromFileTimeUtc(0); tagData.LastAccessTime=new DateTime(9999, 12, 31, 23, 59, 59); rawData=tagData.GetData(); ExtendedUnixData unixData = new ExtendedUnixData(); modTime = unixData.ModificationTime; unixData.ModificationTime=modTime; // Ensure flag is set. rawData = unixData.GetData(); unixData.ModificationTime += TimeSpan.FromSeconds(100); Assert.AreNotEqual(unixData.ModificationTime, modTime); unixData.SetData(rawData, 0, rawData.Length); Assert.AreEqual(0x5455, unixData.TagID, "TagID mismatch"); Assert.AreEqual(modTime, unixData.ModificationTime, "Unix mod time incorrect"); }
private static ITaggedData Create(short tag, byte[] data, int offset, int count) { ITaggedData taggedData; if (tag != 10) { if (tag != 21589) { taggedData = new RawTaggedData(tag); } else { taggedData = new ExtendedUnixData(); } } else { taggedData = new NTTaggedData(); } taggedData.SetData(data, offset, count); return taggedData; }