From 6db0f4d658934b709e9adb3d701a36488f296dd4 Mon Sep 17 00:00:00 2001 From: zoltan Date: Sat, 29 Aug 2009 23:59:04 +0000 Subject: [PATCH] 2009-08-29 Zoltan Varga * net_4_0_System.Core.dll.sources: Add System.IO.MemoryMappedFiles/*.cs and Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mcs@140929 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- class/System.Core/ChangeLog | 5 + .../SafeMemoryMappedFileHandle.cs | 52 ++++++++ .../System.IO.MemoryMappedFiles/ChangeLog | 5 + .../MemoryMappedFile.cs | 134 +++++++++++++++++++++ .../MemoryMappedFileAccess.cs | 47 ++++++++ .../MemoryMappedFileOptions.cs | 43 +++++++ .../MemoryMappedFileRights.cs | 56 +++++++++ .../MemoryMappedViewStream.cs | 40 ++++++ class/System.Core/net_4_0_System.Core.dll.sources | 3 +- 9 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 class/System.Core/Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/ChangeLog create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFile.cs create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs create mode 100644 class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs diff --git a/class/System.Core/ChangeLog b/class/System.Core/ChangeLog index 3777f794c6..31762e8b59 100644 --- a/class/System.Core/ChangeLog +++ b/class/System.Core/ChangeLog @@ -1,3 +1,8 @@ +2009-08-29 Zoltan Varga + + * net_4_0_System.Core.dll.sources: Add System.IO.MemoryMappedFiles/*.cs + and Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs. + 2009-08-27 Atsushi Enomoto * Makefile : add -r:Mono.Posix on required profiles. diff --git a/class/System.Core/Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs b/class/System.Core/Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs new file mode 100644 index 0000000000..a862bf05db --- /dev/null +++ b/class/System.Core/Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs @@ -0,0 +1,52 @@ +// +// SafePipeHandle.cs +// +// Author: +// Zoltan Varga +// +// Copyright (C) 2009 Novell, Inc. http://www.novell.com +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Security.AccessControl; +using System.Security.Permissions; +using System.Security.Principal; + +namespace Microsoft.Win32.SafeHandles +{ + public sealed class SafeMemoryMappedFileHandle : SafeHandleZeroOrMinusOneIsInvalid + { + public SafeMemoryMappedFileHandle (IntPtr preexistingHandle, bool ownsHandle) + : base (ownsHandle) + { + handle = preexistingHandle; + } + + [MonoTODO] + protected override bool ReleaseHandle () + { + throw new NotImplementedException (); + } + } +} + diff --git a/class/System.Core/System.IO.MemoryMappedFiles/ChangeLog b/class/System.Core/System.IO.MemoryMappedFiles/ChangeLog new file mode 100644 index 0000000000..3e2751ee6f --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/ChangeLog @@ -0,0 +1,5 @@ +2009-08-29 Zoltan Varga + + * MemoryMapped*.cs: New files, stubs for the new MemoryMappedFile + apis in net 4.0. + diff --git a/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFile.cs b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFile.cs new file mode 100644 index 0000000000..e27eea08b4 --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFile.cs @@ -0,0 +1,134 @@ +// +// MemoryMappedFile.cs +// +// Authors: +// Zoltan Varga (vargaz@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if NET_4_0 + +using System; +using System.IO; +using System.Collections.Generic; +using Microsoft.Win32.SafeHandles; + +namespace System.IO.MemoryMappedFiles +{ + public class MemoryMappedFile : IDisposable { + + FileStream stream; + + [MonoTODO] + public static MemoryMappedFile CreateFromFile (FileStream fileStream) { + if (fileStream == null) + throw new ArgumentNullException ("fileStream"); + return new MemoryMappedFile () { stream = fileStream }; + } + + [MonoTODO] + public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName) { + throw new NotImplementedException (); + } + + [MonoTODO] + public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName, long capacity) { + throw new NotImplementedException (); + } + + [MonoTODO] + public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName, long capacity, MemoryMappedFileAccess access) { + throw new NotImplementedException (); + } + + /* + [MonoTODO] + public static MemoryMappedFile CreateFromFile (FileStream fileStream, string mapName, long capacity, MemoryMappedFileAccess access, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability inheritability, bool leaveOpen) { + throw new NotImplementedException (); + } + */ + + [MonoTODO] + public static MemoryMappedFile CreateNew (string mapName, long capacity) { + throw new NotImplementedException (); + } + + [MonoTODO] + public static MemoryMappedFile CreateNew (string mapName, long capacity, MemoryMappedFileAccess access) { + throw new NotImplementedException (); + } + + /* + [MonoTODO] + public static MemoryMappedFile CreateNew (string mapName, long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability handleInheritability) { + throw new NotImplementedException (); + } + */ + + [MonoTODO] + public static MemoryMappedFile CreateOrOpen (string mapName, long capacity) { + throw new NotImplementedException (); + } + + [MonoTODO] + public static MemoryMappedFile CreateOrOpen (string mapName, long capacity, MemoryMappedFileAccess access) { + throw new NotImplementedException (); + } + + /* + [MonoTODO] + public static MemoryMappedFile CreateOrOpen (string mapName, long capacity, MemoryMappedFileAccess access, MemoryMappedFileOptions options, MemoryMappedFileSecurity memoryMappedFileSecurity, HandleInheritability handleInheritability) { + throw new NotImplementedException (); + } + */ + + public MemoryMappedViewStream CreateViewStream () { + return CreateViewStream (0, 0); + } + + public MemoryMappedViewStream CreateViewStream (long offset, long size) { + return CreateViewStream (0, 0, MemoryMappedFileAccess.ReadWrite); + } + + [MonoTODO] + public MemoryMappedViewStream CreateViewStream (long offset, long size, MemoryMappedFileAccess access) { + throw new NotImplementedException (); + } + + MemoryMappedFile () { + } + + [MonoTODO] + public void Dispose () { + } + + [MonoTODO] + public SafeMemoryMappedFileHandle SafeMemoryMappedFileHandle { + get { + throw new NotImplementedException (); + } + } + } +} + +#endif \ No newline at end of file diff --git a/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs new file mode 100644 index 0000000000..eaf4473c72 --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs @@ -0,0 +1,47 @@ +// +// MemoryMappedFileAccess.cs +// +// Authors: +// Zoltan Varga (vargaz@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if NET_4_0 + +using System; +using System.IO; + +namespace System.IO.MemoryMappedFiles +{ + public enum MemoryMappedFileAccess { + ReadWrite = 0, + Read = 1, + Write = 2, + CopyOnWrite = 3, + ReadExecute = 4, + ReadWriteExecute = 5 + } +} + +#endif + diff --git a/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs new file mode 100644 index 0000000000..ced4a161b2 --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs @@ -0,0 +1,43 @@ +// +// MemoryMappedFileOptions.cs +// +// Authors: +// Zoltan Varga (vargaz@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if NET_4_0 + +using System; +using System.IO; + +namespace System.IO.MemoryMappedFiles +{ + [Flags] + public enum MemoryMappedFileOptions { + None = 0, + DelayAllocatePages = 0x4000000 + } +} + +#endif diff --git a/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs new file mode 100644 index 0000000000..d6348604d0 --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs @@ -0,0 +1,56 @@ +// +// MemoryMappedFileRights.cs +// +// Authors: +// Zoltan Varga (vargaz@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if NET_4_0 + +using System; +using System.IO; + +namespace System.IO.MemoryMappedFiles +{ + [Flags] + public enum MemoryMappedFileRights { + None = 0, + CopyOnWrite = 1, + Write = 2, + Read = 4, + ReadWrite = 6, + Execute = 8, + ReadExecute = 12, + ReadWriteExecute = 14, + Delete = 0x10000, + ReadPermissions = 0x20000, + ChangePermissions = 0x40000, + TakeOwnership = 0x80000, + FullControl = 0xf000f, + AccessSystemSecurity = 0x1000000, + DelayAllocatePages = 0x4000000 + } +} + +#endif diff --git a/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs new file mode 100644 index 0000000000..d76bd97218 --- /dev/null +++ b/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs @@ -0,0 +1,40 @@ +// +// MemoryMappedViewStream.cs +// +// Authors: +// Zoltan Varga (vargaz@gmail.com) +// +// Copyright (C) 2009, Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if NET_4_0 + +using System; +using System.IO; + +namespace System.IO.MemoryMappedFiles +{ + public sealed class MemoryMappedViewStream : UnmanagedMemoryStream { + } +} + +#endif \ No newline at end of file diff --git a/class/System.Core/net_4_0_System.Core.dll.sources b/class/System.Core/net_4_0_System.Core.dll.sources index 09e7e49154..5214fa6b76 100644 --- a/class/System.Core/net_4_0_System.Core.dll.sources +++ b/class/System.Core/net_4_0_System.Core.dll.sources @@ -15,7 +15,7 @@ System.IO.MemoryMappedFiles/MemoryMappedFile.cs System.IO.MemoryMappedFiles/MemoryMappedFileAccess.cs System.IO.MemoryMappedFiles/MemoryMappedFileOptions.cs System.IO.MemoryMappedFiles/MemoryMappedFileRights.cs -System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs +System.IO.MemoryMappedFiles/MemoryMappedViewStream.cs System.Runtime.CompilerServices/DynamicAttribute.cs System.Runtime.CompilerServices/ExtensionAttribute.cs System.Runtime.CompilerServices/IStrongBox.cs @@ -62,6 +62,7 @@ System.Threading/ReaderWriterLockSlim.cs System.Linq.Expressions/Extensions.cs Microsoft.Win32.SafeHandles/SafePipeHandle.cs +Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs System.IO.Pipes/AnonymousPipeClientStream.cs System.IO.Pipes/AnonymousPipeServerStream.cs System.IO.Pipes/NamedPipeClientStream.cs -- 2.11.4.GIT