diff --git a/src/dotnet/FileSystem+Const.cs b/src/dotnet/FileSystem+Const.cs index decf5599..346d5f2c 100644 --- a/src/dotnet/FileSystem+Const.cs +++ b/src/dotnet/FileSystem+Const.cs @@ -22,6 +22,29 @@ namespace Fsp public partial class FileSystem { + /* CreateOptions */ + public const UInt32 FILE_DIRECTORY_FILE = 0x00000001; + public const UInt32 FILE_WRITE_THROUGH = 0x00000002; + public const UInt32 FILE_SEQUENTIAL_ONLY = 0x00000004; + public const UInt32 FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008; + public const UInt32 FILE_SYNCHRONOUS_IO_ALERT = 0x00000010; + public const UInt32 FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020; + public const UInt32 FILE_NON_DIRECTORY_FILE = 0x00000040; + public const UInt32 FILE_CREATE_TREE_CONNECTION = 0x00000080; + public const UInt32 FILE_COMPLETE_IF_OPLOCKED = 0x00000100; + public const UInt32 FILE_NO_EA_KNOWLEDGE = 0x00000200; + public const UInt32 FILE_OPEN_REMOTE_INSTANCE = 0x00000400; + public const UInt32 FILE_RANDOM_ACCESS = 0x00000800; + public const UInt32 FILE_DELETE_ON_CLOSE = 0x00001000; + public const UInt32 FILE_OPEN_BY_FILE_ID = 0x00002000; + public const UInt32 FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000; + public const UInt32 FILE_NO_COMPRESSION = 0x00008000; + public const UInt32 FILE_OPEN_REQUIRING_OPLOCK = 0x00010000; + public const UInt32 FILE_RESERVE_OPFILTER = 0x00100000; + public const UInt32 FILE_OPEN_REPARSE_POINT = 0x00200000; + public const UInt32 FILE_OPEN_NO_RECALL = 0x00400000; + public const UInt32 FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000; + /* Cleanup */ public const UInt32 CleanupDelete = 0x01; public const UInt32 CleanupSetAllocationSize = 0x02; diff --git a/src/dotnet/FileSystem.cs b/src/dotnet/FileSystem.cs index 7c5a8e31..1b2eb08c 100644 --- a/src/dotnet/FileSystem.cs +++ b/src/dotnet/FileSystem.cs @@ -215,15 +215,17 @@ namespace Fsp UInt32 CreateOptions, UInt32 GrantedAccess, UInt32 FileAttributes, - Object SecurityDescriptor, + Byte[] SecurityDescriptor, UInt64 AllocationSize, out Object FileNode, out Object FileDesc, - out OpenFileInfo OpenFileInfo) + out FileInfo FileInfo, + out String NormalizedName) { FileNode = default(Object); FileDesc = default(Object); - OpenFileInfo = default(OpenFileInfo); + FileInfo = default(FileInfo); + NormalizedName = default(String); return STATUS_INVALID_DEVICE_REQUEST; } protected virtual Int32 Open( @@ -232,11 +234,13 @@ namespace Fsp UInt32 GrantedAccess, out Object FileNode, out Object FileDesc, - out OpenFileInfo OpenFileInfo) + out FileInfo FileInfo, + out String NormalizedName) { FileNode = default(Object); FileDesc = default(Object); - OpenFileInfo = default(OpenFileInfo); + FileInfo = default(FileInfo); + NormalizedName = default(String); return STATUS_INVALID_DEVICE_REQUEST; } protected virtual Int32 Overwrite( @@ -510,12 +514,13 @@ namespace Fsp IntPtr SecurityDescriptor, UInt64 AllocationSize, ref FullContext FullContext, - out OpenFileInfo OpenFileInfo) + ref OpenFileInfo OpenFileInfo) { FileSystem self = (FileSystem)Api.GetUserContext(FileSystem); try { Object FileNode, FileDesc; + String NormalizedName; Int32 Result; Result = self.Create( FileName, @@ -526,13 +531,18 @@ namespace Fsp AllocationSize, out FileNode, out FileDesc, - out OpenFileInfo); - Api.SetFullContext(ref FullContext, FileNode, FileDesc); + out OpenFileInfo.FileInfo, + out NormalizedName); + if (0 <= Result) + { + if (null != NormalizedName) + OpenFileInfo.SetNormalizedName(NormalizedName); + Api.SetFullContext(ref FullContext, FileNode, FileDesc); + } return Result; } catch (Exception ex) { - OpenFileInfo = default(OpenFileInfo); return self.ExceptionHandler(ex); } } @@ -542,12 +552,13 @@ namespace Fsp UInt32 CreateOptions, UInt32 GrantedAccess, ref FullContext FullContext, - out OpenFileInfo OpenFileInfo) + ref OpenFileInfo OpenFileInfo) { FileSystem self = (FileSystem)Api.GetUserContext(FileSystem); try { Object FileNode, FileDesc; + String NormalizedName; Int32 Result; Result = self.Open( FileName, @@ -555,13 +566,18 @@ namespace Fsp GrantedAccess, out FileNode, out FileDesc, - out OpenFileInfo); - Api.SetFullContext(ref FullContext, FileNode, FileDesc); + out OpenFileInfo.FileInfo, + out NormalizedName); + if (0 <= Result) + { + if (null != NormalizedName) + OpenFileInfo.SetNormalizedName(NormalizedName); + Api.SetFullContext(ref FullContext, FileNode, FileDesc); + } return Result; } catch (Exception ex) { - OpenFileInfo = default(OpenFileInfo); return self.ExceptionHandler(ex); } } diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index c9db4a63..cb1eeddf 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -130,13 +130,13 @@ namespace Fsp.Interop } [StructLayout(LayoutKind.Sequential)] - public struct OpenFileInfo + internal struct OpenFileInfo { - public FileInfo FileInfo; - public IntPtr NormalizedName; - public UInt16 NormalizedNameSize; + internal FileInfo FileInfo; + internal IntPtr NormalizedName; + internal UInt16 NormalizedNameSize; - public unsafe void SetNormalizedName(String Value) + internal unsafe void SetNormalizedName(String Value) { UInt16 *P = (UInt16 *)NormalizedName; int Size = Value.Length; @@ -211,7 +211,7 @@ namespace Fsp.Interop IntPtr SecurityDescriptor, UInt64 AllocationSize, ref FullContext FullContext, - out OpenFileInfo OpenFileInfo); + ref OpenFileInfo OpenFileInfo); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate Int32 Open( IntPtr FileSystem, @@ -219,7 +219,7 @@ namespace Fsp.Interop UInt32 CreateOptions, UInt32 GrantedAccess, ref FullContext FullContext, - out OpenFileInfo OpenFileInfo); + ref OpenFileInfo OpenFileInfo); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate Int32 Overwrite( IntPtr FileSystem,