diff --git a/src/dotnet/FileSystem.cs b/src/dotnet/FileSystem.cs index d28c7fb6..35b792ce 100644 --- a/src/dotnet/FileSystem.cs +++ b/src/dotnet/FileSystem.cs @@ -74,73 +74,90 @@ namespace Fsp } /* properties */ - public void SetSectorSize(UInt16 SectorSize) + public UInt16 SectorSize { - _VolumeParams.SectorSize = SectorSize; + get { return _VolumeParams.SectorSize; } + set { _VolumeParams.SectorSize = value; } } - public void SetSectorsPerAllocationUnit(UInt16 SectorsPerAllocationUnit) + public UInt16 SectorsPerAllocationUnit { - _VolumeParams.SectorsPerAllocationUnit = SectorsPerAllocationUnit; + get { return _VolumeParams.SectorsPerAllocationUnit; } + set { _VolumeParams.SectorsPerAllocationUnit = value; } } - public void SetMaxComponentLength(UInt16 MaxComponentLength) + public UInt16 MaxComponentLength { - _VolumeParams.MaxComponentLength = MaxComponentLength; + get { return _VolumeParams.MaxComponentLength; } + set { _VolumeParams.MaxComponentLength = value; } } - public void SetVolumeCreationTime(UInt64 VolumeCreationTime) + public UInt64 VolumeCreationTime { - _VolumeParams.VolumeCreationTime = VolumeCreationTime; + get { return _VolumeParams.VolumeCreationTime; } + set { _VolumeParams.VolumeCreationTime = value; } } - public void SetVolumeSerialNumber(UInt32 VolumeSerialNumber) + public UInt32 VolumeSerialNumber { - _VolumeParams.VolumeSerialNumber = VolumeSerialNumber; + get { return _VolumeParams.VolumeSerialNumber; } + set { _VolumeParams.VolumeSerialNumber = value; } } - public void SetFileInfoTimeout(UInt32 FileInfoTimeout) + public UInt32 FileInfoTimeout { - _VolumeParams.FileInfoTimeout = FileInfoTimeout; + get { return _VolumeParams.FileInfoTimeout; } + set { _VolumeParams.FileInfoTimeout = value; } } - public void SetCaseSensitiveSearch(Boolean CaseSensitiveSearch) + public Boolean CaseSensitiveSearch { - _VolumeParams.Flags |= CaseSensitiveSearch ? VolumeParams.CaseSensitiveSearch : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.CaseSensitiveSearch); } + set { _VolumeParams.Flags |= (value ? VolumeParams.CaseSensitiveSearch : 0); } } - public void SetCasePreservedNames(Boolean CasePreservedNames) + public Boolean CasePreservedNames { - _VolumeParams.Flags |= CasePreservedNames ? VolumeParams.CasePreservedNames : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.CasePreservedNames); } + set { _VolumeParams.Flags |= (value ? VolumeParams.CasePreservedNames : 0); } } - public void SetUnicodeOnDisk(Boolean UnicodeOnDisk) + public Boolean UnicodeOnDisk { - _VolumeParams.Flags |= UnicodeOnDisk ? VolumeParams.UnicodeOnDisk : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.UnicodeOnDisk); } + set { _VolumeParams.Flags |= (value ? VolumeParams.UnicodeOnDisk : 0); } } - public void SetPersistentAcls(Boolean PersistentAcls) + public Boolean PersistentAcls { - _VolumeParams.Flags |= PersistentAcls ? VolumeParams.PersistentAcls : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.PersistentAcls); } + set { _VolumeParams.Flags |= (value ? VolumeParams.PersistentAcls : 0); } } - public void SetReparsePoints(Boolean ReparsePoints) + public Boolean ReparsePoints { - _VolumeParams.Flags |= ReparsePoints ? VolumeParams.ReparsePoints : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.ReparsePoints); } + set { _VolumeParams.Flags |= (value ? VolumeParams.ReparsePoints : 0); } } - public void SetReparsePointsAccessCheck(Boolean ReparsePointsAccessCheck) + public Boolean ReparsePointsAccessCheck { - _VolumeParams.Flags |= ReparsePointsAccessCheck ? VolumeParams.ReparsePointsAccessCheck : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.ReparsePointsAccessCheck); } + set { _VolumeParams.Flags |= (value ? VolumeParams.ReparsePointsAccessCheck : 0); } } - public void SetNamedStreams(Boolean NamedStreams) + public Boolean NamedStreams { - _VolumeParams.Flags |= NamedStreams ? VolumeParams.NamedStreams : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.NamedStreams); } + set { _VolumeParams.Flags |= (value ? VolumeParams.NamedStreams : 0); } } - public void SetPostCleanupWhenModifiedOnly(Boolean PostCleanupWhenModifiedOnly) + public Boolean PostCleanupWhenModifiedOnly { - _VolumeParams.Flags |= PostCleanupWhenModifiedOnly ? VolumeParams.PostCleanupWhenModifiedOnly : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.PostCleanupWhenModifiedOnly); } + set { _VolumeParams.Flags |= (value ? VolumeParams.PostCleanupWhenModifiedOnly : 0); } } - public void SetPassQueryDirectoryPattern(Boolean PassQueryDirectoryPattern) + public Boolean PassQueryDirectoryPattern { - _VolumeParams.Flags |= PassQueryDirectoryPattern ? VolumeParams.PassQueryDirectoryPattern : 0; + get { return 0 != (_VolumeParams.Flags & VolumeParams.PassQueryDirectoryPattern); } + set { _VolumeParams.Flags |= (value ? VolumeParams.PassQueryDirectoryPattern : 0); } } - public void SetPrefix(String Prefix) + public String Prefix { - _VolumeParams.SetPrefix(Prefix); + get { return _VolumeParams.GetPrefix(); } + set { _VolumeParams.SetPrefix(value); } } - public void SetFileSystemName(String FileSystemName) + public String FileSystemName { - _VolumeParams.SetFileSystemName(FileSystemName); + get { return _VolumeParams.GetFileSystemName(); } + set { _VolumeParams.SetFileSystemName(value); } } /* control */ diff --git a/src/dotnet/Interop.cs b/src/dotnet/Interop.cs index 5ce3935e..2f4274e6 100644 --- a/src/dotnet/Interop.cs +++ b/src/dotnet/Interop.cs @@ -61,6 +61,11 @@ namespace Fsp.Interop internal unsafe fixed UInt16 Prefix[PrefixSize]; internal unsafe fixed UInt16 FileSystemName[FileSystemNameSize]; + internal unsafe String GetPrefix() + { + fixed (UInt16 *P = Prefix) + return Marshal.PtrToStringUni((IntPtr)P); + } internal unsafe void SetPrefix(String Value) { fixed (UInt16 *P = Prefix) @@ -73,6 +78,11 @@ namespace Fsp.Interop P[Size] = 0; } } + internal unsafe String GetFileSystemName() + { + fixed (UInt16 *P = FileSystemName) + return Marshal.PtrToStringUni((IntPtr)P); + } internal unsafe void SetFileSystemName(String Value) { fixed (UInt16 *P = FileSystemName) diff --git a/tst/passthrough-dotnet/Program.cs b/tst/passthrough-dotnet/Program.cs index 8e2976f0..280fe240 100644 --- a/tst/passthrough-dotnet/Program.cs +++ b/tst/passthrough-dotnet/Program.cs @@ -279,24 +279,24 @@ namespace passthrough public Ptfs() : base() { - SetSectorSize(ALLOCATION_UNIT); - SetSectorsPerAllocationUnit(1); - SetMaxComponentLength(255); - SetFileInfoTimeout(1000); - SetCaseSensitiveSearch(false); - SetCasePreservedNames(true); - SetUnicodeOnDisk(true); - SetPersistentAcls(true); - SetPostCleanupWhenModifiedOnly(true); - SetPassQueryDirectoryPattern(true); + SectorSize = ALLOCATION_UNIT; + SectorsPerAllocationUnit = 1; + MaxComponentLength = 255; + FileInfoTimeout = 1000; + CaseSensitiveSearch = false; + CasePreservedNames = true; + UnicodeOnDisk = true; + PersistentAcls = true; + PostCleanupWhenModifiedOnly = true; + PassQueryDirectoryPattern = true; } public void SetPath(String value) { _Path = Path.GetFullPath(value); if (_Path.EndsWith("\\")) _Path = _Path.Substring(0, _Path.Length - 1); - SetVolumeCreationTime((UInt64)File.GetCreationTimeUtc(_Path).ToFileTimeUtc()); - SetVolumeSerialNumber(0); + VolumeCreationTime = (UInt64)File.GetCreationTimeUtc(_Path).ToFileTimeUtc(); + VolumeSerialNumber = 0; } protected override Int32 ExceptionHandler(Exception ex) @@ -775,7 +775,7 @@ namespace passthrough FailMessage = "cannot create file system"; Ptfs = new Ptfs(); - Ptfs.SetPrefix(VolumePrefix); + Ptfs.Prefix = VolumePrefix; Ptfs.SetPath(PassThrough); FailMessage = "cannot mount file system";