コード例 #1
0
        bool SetTimestampsFromInfoZipUnixOriginal(IList <ExtraField> fields, WindowsZipEntry entry)
        {
            if (fields == null || fields.Count == 0)
            {
                return(false);
            }

            DateTime modTime = DateTime.MinValue;
            DateTime accTime = DateTime.MinValue;

            ForEachExtraField(fields, true, (ExtraField ef) => {
                var izef = new ExtraField_InfoZipUnixOriginal(ef);
                SetOriginalUnixTimeStampTimes(izef, ref modTime, ref accTime);
            });
            if (modTime == DateTime.MinValue)
            {
                ForEachExtraField(fields, false, (ExtraField ef) => SetOriginalUnixTimeStampTimes(new ExtraField_InfoZipUnixOriginal(ef), ref modTime, ref accTime));
            }

            if (modTime != DateTime.MinValue)
            {
                entry.ModificationTime = modTime;
            }

            // We ignore ID/GID here because it's less important than timestamps which may be set from other
            // fields should this one lack any of them.
            return(modTime != DateTime.MinValue || accTime != DateTime.MinValue);
        }
コード例 #2
0
        void SetOriginalUnixTimeStampTimes(ExtraField_InfoZipUnixOriginal tstamp, ref DateTime modTime, ref DateTime accTime)
        {
            if (!tstamp.DataValid)
            {
                return;
            }

            if (tstamp.ModificationTime != DateTime.MinValue)
            {
                modTime = tstamp.ModificationTime;
            }

            if (tstamp.AccessTime != DateTime.MinValue)
            {
                accTime = tstamp.AccessTime;
            }
        }