Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Matos <joao@tritao.eu>2016-05-23 22:05:31 +0300
committerJoao Matos <joao@tritao.eu>2016-05-23 22:19:22 +0300
commitbc1967e73b7736c2cb950e65cc1930a7cbd28468 (patch)
tree0b9bd8d377eda330d445f5709a266b18c10ce06a /mcs/class/WindowsBase
parent8d403e73a7e63c0af50d57cd05eff8970d9980d6 (diff)
[System.IO.Compression] Fixed date time handling of Zip entries.
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r--mcs/class/WindowsBase/Makefile2
-rw-r--r--mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs21
-rw-r--r--mcs/class/WindowsBase/ZipSharp/ZipFileInfo.cs4
3 files changed, 24 insertions, 3 deletions
diff --git a/mcs/class/WindowsBase/Makefile b/mcs/class/WindowsBase/Makefile
index 842c1ed0ebe..d3eaf78bc82 100644
--- a/mcs/class/WindowsBase/Makefile
+++ b/mcs/class/WindowsBase/Makefile
@@ -6,7 +6,7 @@ LIBRARY = WindowsBase.dll
LIB_REFS = System System.Xml
LIB_MCS_FLAGS = -unsafe
TEST_MCS_FLAGS = -unsafe
-TEST_LIB_REFS = WindowsBase System System.Xml System.Core
+TEST_LIB_REFS = WindowsBase System System.Xml System.Core System.IO.Compression
ifeq (2.0, $(FRAMEWORK_VERSION))
LIB_MCS_FLAGS += -d:NET_3_0
diff --git a/mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs b/mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs
index 933449052f3..808aa468d38 100644
--- a/mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs
+++ b/mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.IO.Compression;
using System.IO.Packaging;
using System.Linq;
using System.Text;
@@ -116,7 +117,7 @@ namespace MonoTests.System.IO.Packaging {
package = Package.Open (path);
package.Close ();
package = Package.Open (path);
- }
+ }
[Test]
public void Close_FileStreamNotClosed ()
@@ -416,5 +417,23 @@ namespace MonoTests.System.IO.Packaging {
File.Create (path).Close ();
package = Package.Open (path, FileMode.OpenOrCreate, FileAccess.Write);
}
+
+ [Test]
+ public void Check_ZipDateTime ()
+ {
+ using (var zipStream = new FileStream (path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+ using (package = Package.Open (zipStream, FileMode.OpenOrCreate)) {
+ var part = package.CreatePart (new Uri ("/test", UriKind.Relative), "test/type");
+ using (var stream = part.GetStream ())
+ stream.Write (new byte [1024 * 1024], 0, 1024 * 1024);
+ }
+
+ using (var stream = new FileStream (path, FileMode.Open, FileAccess.Read))
+ using (var archive = new ZipArchive(stream))
+ {
+ foreach (var entry in archive.Entries)
+ Assert.AreEqual (entry.LastWriteTime.Year, DateTime.Now.Year);
+ }
+ }
}
}
diff --git a/mcs/class/WindowsBase/ZipSharp/ZipFileInfo.cs b/mcs/class/WindowsBase/ZipSharp/ZipFileInfo.cs
index 2cbea32a40c..2a81a73959b 100644
--- a/mcs/class/WindowsBase/ZipSharp/ZipFileInfo.cs
+++ b/mcs/class/WindowsBase/ZipSharp/ZipFileInfo.cs
@@ -5,9 +5,11 @@
//
using System;
+using System.Runtime.InteropServices;
namespace zipsharp
{
+ [StructLayoutAttribute (LayoutKind.Sequential)]
struct ZipFileInfo
{
ZipTime date;
@@ -38,7 +40,7 @@ namespace zipsharp
public ZipFileInfo (DateTime fileTime)
{
date = new ZipTime (fileTime);
- dosDate = new IntPtr ((int)fileTime.ToFileTime ());
+ dosDate = IntPtr.Zero;
internalFileAttributes = IntPtr.Zero;
externalFileAttributes = IntPtr.Zero;
}