private int ProcessExtraFieldWindowsTimes(byte[] buffer, int j, Int16 dataSize, long posn)
{
// The NTFS filetimes are 64-bit unsigned integers, stored in Intel
// (least significant byte first) byte order. They are expressed as the
// number of 1.0E-07 seconds (1/10th microseconds!) past WinNT "epoch",
// which is "01-Jan-1601 00:00:00 UTC".
//
// HeaderId 2 bytes 0x000a == NTFS stuff
// Datasize 2 bytes ?? (usually 32)
// reserved 4 bytes ??
// timetag 2 bytes 0x0001 == time
// size 2 bytes 24 == 8 bytes each for ctime, mtime, atime
// mtime 8 bytes win32 ticks since win32epoch
// atime 8 bytes win32 ticks since win32epoch
// ctime 8 bytes win32 ticks since win32epoch
if (dataSize != 32)
throw new BadReadException(String.Format(" Unexpected size (0x{0:X4}) for NTFS times extra field at position 0x{1:X16}", dataSize, posn));
j += 4; // reserved
Int16 timetag = (Int16)(buffer[j] + buffer[j + 1] * 256);
Int16 addlsize = (Int16)(buffer[j + 2] + buffer[j + 3] * 256);
j += 4; // tag and size
if (timetag == 0x0001 && addlsize == 24)
{
Int64 z = BitConverter.ToInt64(buffer, j);
this._Mtime = DateTime.FromFileTimeUtc(z);
j += 8;
// At this point the library *could* set the LastModified value
// to coincide with the Mtime value. In theory, they refer to
// the same property of the file, and should be the same anyway,
// allowing for differences in precision. But they are
// independent quantities in the zip archive, and this library
// will keep them separate in the object model. There is no ill
// effect from this, because as files are extracted, the
// higher-precision value (Mtime) is used if it is present.
// Apps may wish to compare the Mtime versus LastModified
// values, but any difference when both are present is not
// germaine to the correctness of the library. but note: when
// explicitly setting either value, both are set. See the setter
// for LastModified or the SetNtfsTimes() method.
z = BitConverter.ToInt64(buffer, j);
this._Atime = DateTime.FromFileTimeUtc(z);
j += 8;
z = BitConverter.ToInt64(buffer, j);
this._Ctime = DateTime.FromFileTimeUtc(z);
j += 8;
_ntfsTimesAreSet = true;
_timestamp |= ZipEntryTimestamp.Windows;
_emitNtfsTimes = true;
}
return j;
}