Esempio n. 1
0
        public void CreatedDirectoryEntriesUsesExpectedTime(ZipEntryFactory.TimeSetting timeSetting)
        {
            string tempDir = GetTempFilePath();

            if (tempDir == null)
            {
                Assert.Inconclusive("No permission to execute this test?");
            }

            tempDir = Path.Combine(tempDir, "SharpZipTest");

            // Note the seconds returned will be even!
            var expectedTime = new DateTime(2100, 2, 27, 11, 07, 56);

            Directory.CreateDirectory(tempDir);

            try
            {
                string tempFile = Path.Combine(tempDir, "SharpZipTest.Zip");

                using (FileStream f = File.Create(tempFile, 1024))
                {
                    f.WriteByte(0);
                }

                DateTime dirTime = DateTime.MinValue;

                if (timeSetting == ZipEntryFactory.TimeSetting.CreateTime)
                {
                    Directory.SetCreationTime(tempFile, expectedTime);
                    dirTime = Directory.GetCreationTime(tempDir);
                }

                if (timeSetting == ZipEntryFactory.TimeSetting.LastAccessTime)
                {
                    Directory.SetLastAccessTime(tempDir, expectedTime);
                    dirTime = Directory.GetLastAccessTime(tempDir);
                }

                if (timeSetting == ZipEntryFactory.TimeSetting.LastWriteTime)
                {
                    Directory.SetLastWriteTime(tempDir, expectedTime);
                    dirTime = Directory.GetLastWriteTime(tempDir);
                }

                if (dirTime != expectedTime)
                {
                    Assert.Inconclusive("Directory time could not be altered");
                }

                var factory = new ZipEntryFactory();

                factory.Setting = timeSetting;

                var entry = factory.MakeDirectoryEntry(tempDir);
                Assert.AreEqual(expectedTime, entry.DateTime);
            }
            finally
            {
                Directory.Delete(tempDir, true);
            }
        }
Esempio n. 2
0
 public ZipEntryFactory(ZipEntryFactory.TimeSetting timeSetting)
 {
     this.timeSetting_ = timeSetting;
 }
 public ZipEntryFactory(DateTime time)
 {
     this.timeSetting_   = ZipEntryFactory.TimeSetting.Fixed;
     this.FixedDateTime  = time;
     this.nameTransform_ = new ZipNameTransform();
 }
Esempio n. 4
0
 // Token: 0x0600094C RID: 2380 RVA: 0x00033F45 File Offset: 0x00032145
 public ZipEntryFactory(ZipEntryFactory.TimeSetting timeSetting)
 {
     this.timeSetting_   = timeSetting;
     this.nameTransform_ = new ZipNameTransform();
 }
 /// <summary>
 /// Initialise a new instance of <see cref="FastZip"/> using the specified <see cref="ZipEntryFactory.TimeSetting"/>
 /// </summary>
 /// <param name="timeSetting">The <see cref="ZipEntryFactory.TimeSetting">time setting</see> to use when creating or extracting <see cref="ZipEntry">Zip entries</see>.</param>
 /// <remarks>Using <see cref="ZipEntryFactory.TimeSetting.LastAccessTime">TimeSetting.LastAccessTime</see><see cref="ZipEntryFactory.TimeSetting.LastAccessTimeUtc">[Utc]</see> when
 /// creating an archive will set the file time to the moment of reading.
 /// </remarks>
 public FastZip(ZipEntryFactory.TimeSetting timeSetting)
 {
     entryFactory_             = new ZipEntryFactory(timeSetting);
     restoreDateTimeOnExtract_ = true;
 }