diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2016-05-27 21:20:18 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2016-05-27 21:20:18 +0300 |
commit | ee5a06c1a0467518249a67fd900c62b9bb8f25d3 (patch) | |
tree | 6d4c9416e17e4a443cf64e812a2f2831d5a46b2b /mcs/class/System.IO.Compression | |
parent | 87b55c5dc97207f668d0a9b696afc57e95faf35f (diff) | |
parent | b977ec8ef9a6795352e2b1cd0c4173b1a66e4ee1 (diff) |
Merge pull request #3037 from mono/system_io_compression_datetime
[System.IO.Compression/.Filesystem] Fixed handling of date/time for Zip entries
Diffstat (limited to 'mcs/class/System.IO.Compression')
-rw-r--r-- | mcs/class/System.IO.Compression/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs | 8 | ||||
-rw-r--r-- | mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs | 25 |
2 files changed, 26 insertions, 7 deletions
diff --git a/mcs/class/System.IO.Compression/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs b/mcs/class/System.IO.Compression/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs index acb5e2ddc29..f19a9c27647 100644 --- a/mcs/class/System.IO.Compression/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs +++ b/mcs/class/System.IO.Compression/SharpCompress/Archive/Zip/ZipWritableArchiveEntry.cs @@ -10,7 +10,6 @@ namespace SharpCompress.Archive.Zip { private readonly string path; private readonly long size; - private readonly DateTime? lastModified; private readonly bool closeStream; private readonly Stream stream; private bool isDisposed; @@ -22,7 +21,7 @@ namespace SharpCompress.Archive.Zip this.stream = stream; this.path = path; this.size = size; - this.lastModified = lastModified; + this.LastModifiedTime = lastModified; this.closeStream = closeStream; } @@ -46,11 +45,6 @@ namespace SharpCompress.Archive.Zip get { return size; } } - public override DateTime? LastModifiedTime - { - get { return lastModified; } - } - public override DateTime? CreatedTime { get { return null; } diff --git a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs index 36903c675b4..d461600299f 100644 --- a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs +++ b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs @@ -239,6 +239,31 @@ namespace MonoTests.System.IO.Compression } [Test] + public void ZipEnumerateEntriesModifiedTime() + { + File.Copy("archive.zip", "test.zip", overwrite: true); + var date = DateTimeOffset.Now; + using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + ZipArchiveMode.Update)) + { + var entry = archive.GetEntry("foo.txt"); + entry.LastWriteTime = date; + } + + using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), + ZipArchiveMode.Read)) + { + var entry = archive.GetEntry("foo.txt"); + Assert.AreEqual(entry.LastWriteTime.Year, date.Year); + Assert.AreEqual(entry.LastWriteTime.Month, date.Month); + Assert.AreEqual(entry.LastWriteTime.Day, date.Day); + + } + + File.Delete ("test.zip"); + } + + [Test] public void ZipEnumerateEntriesReadMode() { File.Copy("archive.zip", "test.zip", overwrite: true); |