mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
src: dotnet: WIP
This commit is contained in:
parent
fc51b7cc22
commit
8e7e959d8a
@ -15,11 +15,134 @@
|
||||
* software.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Fsp.Interop;
|
||||
|
||||
namespace Fsp
|
||||
{
|
||||
|
||||
public class FileSystem
|
||||
public class FileSystem : IDisposable
|
||||
{
|
||||
/* ctor/dtor */
|
||||
public FileSystem()
|
||||
{
|
||||
_VolumeParams.Flags = VolumeParams.UmFileContextIsFullContext;
|
||||
}
|
||||
|
||||
~FileSystem()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(true);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (IntPtr.Zero != _FileSystem)
|
||||
{
|
||||
Api.FspFileSystemDelete(_FileSystem);
|
||||
_FileSystem = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
/* properties */
|
||||
public void SetSectorSize(UInt16 SectorSize)
|
||||
{
|
||||
_VolumeParams.SectorSize = SectorSize;
|
||||
}
|
||||
public void SetSectorsPerAllocationUnit(UInt16 SectorsPerAllocationUnit)
|
||||
{
|
||||
_VolumeParams.SectorsPerAllocationUnit = SectorsPerAllocationUnit;
|
||||
}
|
||||
public void SetMaxComponentLength(UInt16 MaxComponentLength)
|
||||
{
|
||||
_VolumeParams.MaxComponentLength = MaxComponentLength;
|
||||
}
|
||||
public void SetVolumeCreationTime(UInt64 VolumeCreationTime)
|
||||
{
|
||||
_VolumeParams.VolumeCreationTime = VolumeCreationTime;
|
||||
}
|
||||
public void SetVolumeSerialNumber(UInt32 VolumeSerialNumber)
|
||||
{
|
||||
_VolumeParams.VolumeSerialNumber = VolumeSerialNumber;
|
||||
}
|
||||
public void SetFileInfoTimeout(UInt32 FileInfoTimeout)
|
||||
{
|
||||
_VolumeParams.FileInfoTimeout = FileInfoTimeout;
|
||||
}
|
||||
public void SetCaseSensitiveSearch(Boolean CaseSensitiveSearch)
|
||||
{
|
||||
_VolumeParams.Flags = CaseSensitiveSearch ? VolumeParams.CaseSensitiveSearch : 0;
|
||||
}
|
||||
public void SetCasePreservedNames(Boolean CasePreservedNames)
|
||||
{
|
||||
_VolumeParams.Flags = CasePreservedNames ? VolumeParams.CasePreservedNames : 0;
|
||||
}
|
||||
public void SetUnicodeOnDisk(Boolean UnicodeOnDisk)
|
||||
{
|
||||
_VolumeParams.Flags = UnicodeOnDisk ? VolumeParams.UnicodeOnDisk : 0;
|
||||
}
|
||||
public void SetPersistentAcls(Boolean PersistentAcls)
|
||||
{
|
||||
_VolumeParams.Flags = PersistentAcls ? VolumeParams.PersistentAcls : 0;
|
||||
}
|
||||
public void SetReparsePoints(Boolean ReparsePoints)
|
||||
{
|
||||
_VolumeParams.Flags = ReparsePoints ? VolumeParams.ReparsePoints : 0;
|
||||
}
|
||||
public void SetReparsePointsAccessCheck(Boolean ReparsePointsAccessCheck)
|
||||
{
|
||||
_VolumeParams.Flags = ReparsePointsAccessCheck ? VolumeParams.ReparsePointsAccessCheck : 0;
|
||||
}
|
||||
public void SetNamedStreams(Boolean NamedStreams)
|
||||
{
|
||||
_VolumeParams.Flags = NamedStreams ? VolumeParams.NamedStreams : 0;
|
||||
}
|
||||
public void SetPostCleanupWhenModifiedOnly(Boolean PostCleanupWhenModifiedOnly)
|
||||
{
|
||||
_VolumeParams.Flags = PostCleanupWhenModifiedOnly ? VolumeParams.PostCleanupWhenModifiedOnly : 0;
|
||||
}
|
||||
public void SetPassQueryDirectoryPattern(Boolean PassQueryDirectoryPattern)
|
||||
{
|
||||
_VolumeParams.Flags = PassQueryDirectoryPattern ? VolumeParams.PassQueryDirectoryPattern : 0;
|
||||
}
|
||||
public void SetPrefix(String Prefix)
|
||||
{
|
||||
int Size = Prefix.Length;
|
||||
if (Size > VolumeParams.PrefixSize - 1)
|
||||
Size = VolumeParams.PrefixSize - 1;
|
||||
unsafe
|
||||
{
|
||||
fixed (UInt16 *P = _VolumeParams.Prefix)
|
||||
{
|
||||
for (int I = 0; Size > I; I++)
|
||||
P[I] = Prefix[I];
|
||||
P[Size] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetFileSystemName(String FileSystemName)
|
||||
{
|
||||
int Size = FileSystemName.Length;
|
||||
if (Size > VolumeParams.FileSystemNameSize - 1)
|
||||
Size = VolumeParams.FileSystemNameSize - 1;
|
||||
unsafe
|
||||
{
|
||||
fixed (UInt16 *P = _VolumeParams.FileSystemName)
|
||||
{
|
||||
for (int I = 0; Size > I; I++)
|
||||
P[I] = FileSystemName[I];
|
||||
P[Size] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VolumeParams _VolumeParams;
|
||||
private IntPtr _FileSystem;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,20 +25,7 @@ namespace Fsp.Interop
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct VolumeParams
|
||||
{
|
||||
internal UInt16 Version;
|
||||
internal UInt16 SectorSize;
|
||||
internal UInt16 SectorsPerAllocationUnit;
|
||||
internal UInt16 MaxComponentLength;
|
||||
internal UInt64 VolumeCreationTime;
|
||||
internal UInt32 VolumeSerialNumber;
|
||||
internal UInt32 TransactTimeout;
|
||||
internal UInt32 IrpTimeout;
|
||||
internal UInt32 IrpCapacity;
|
||||
internal UInt32 FileInfoTimeout;
|
||||
internal UInt32 Flags;
|
||||
internal unsafe fixed UInt16 Prefix[192];
|
||||
internal unsafe fixed UInt16 FileSystemName[16];
|
||||
|
||||
/* const */
|
||||
internal const UInt32 CaseSensitiveSearch = 0x00000001;
|
||||
internal const UInt32 CasePreservedNames = 0x00000002;
|
||||
internal const UInt32 UnicodeOnDisk = 0x00000004;
|
||||
@ -54,6 +41,23 @@ namespace Fsp.Interop
|
||||
internal const UInt32 AlwaysUseDoubleBuffering = 0x00001000;
|
||||
internal const UInt32 UmFileContextIsUserContext2 = 0x00010000;
|
||||
internal const UInt32 UmFileContextIsFullContext = 0x00020000;
|
||||
internal const int PrefixSize = 192;
|
||||
internal const int FileSystemNameSize = 16;
|
||||
|
||||
/* fields */
|
||||
internal UInt16 Version;
|
||||
internal UInt16 SectorSize;
|
||||
internal UInt16 SectorsPerAllocationUnit;
|
||||
internal UInt16 MaxComponentLength;
|
||||
internal UInt64 VolumeCreationTime;
|
||||
internal UInt32 VolumeSerialNumber;
|
||||
internal UInt32 TransactTimeout;
|
||||
internal UInt32 IrpTimeout;
|
||||
internal UInt32 IrpCapacity;
|
||||
internal UInt32 FileInfoTimeout;
|
||||
internal UInt32 Flags;
|
||||
internal unsafe fixed UInt16 Prefix[PrefixSize];
|
||||
internal unsafe fixed UInt16 FileSystemName[FileSystemNameSize];
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@ -84,8 +88,7 @@ namespace Fsp.Interop
|
||||
internal struct OpenFileInfo
|
||||
{
|
||||
internal FileInfo FileInfo;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
internal String NormalizedName;
|
||||
internal IntPtr NormalizedName;
|
||||
internal UInt16 NormalizedNameSize;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user