mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
src: dotnet: WIP
This commit is contained in:
parent
02cec420e7
commit
47b81a8025
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Security.AccessControl;
|
||||||
|
|
||||||
using Fsp.Interop;
|
using Fsp.Interop;
|
||||||
|
|
||||||
namespace Fsp
|
namespace Fsp
|
||||||
@ -28,18 +30,15 @@ namespace Fsp
|
|||||||
{
|
{
|
||||||
_VolumeParams.Flags = VolumeParams.UmFileContextIsFullContext;
|
_VolumeParams.Flags = VolumeParams.UmFileContextIsFullContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileSystem()
|
~FileSystem()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(true);
|
GC.SuppressFinalize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Dispose(bool disposing)
|
protected void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (IntPtr.Zero != _FileSystem)
|
if (IntPtr.Zero != _FileSystem)
|
||||||
@ -119,6 +118,60 @@ namespace Fsp
|
|||||||
_VolumeParams.FileSystemName = FileSystemName;
|
_VolumeParams.FileSystemName = FileSystemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* control */
|
||||||
|
Int32 Preflight(String MountPoint)
|
||||||
|
{
|
||||||
|
return Api.FspFileSystemPreflight(
|
||||||
|
0 < _VolumeParams.Prefix.Length ? "WinFsp.Net" : "WinFsp.Disk",
|
||||||
|
MountPoint);
|
||||||
|
}
|
||||||
|
Int32 Mount(String MountPoint,
|
||||||
|
GenericSecurityDescriptor SecurityDescriptor = null,
|
||||||
|
Boolean Synchronized = false,
|
||||||
|
UInt32 DebugLog = 0)
|
||||||
|
{
|
||||||
|
FileSystemInterface Intf; // ???: padding
|
||||||
|
Int32 Result;
|
||||||
|
Result = Api.FspFileSystemCreate(
|
||||||
|
0 < _VolumeParams.Prefix.Length ? "WinFsp.Net" : "WinFsp.Disk",
|
||||||
|
ref _VolumeParams, ref Intf, out _FileSystem);
|
||||||
|
if (0 <= Result)
|
||||||
|
{
|
||||||
|
#if false
|
||||||
|
_FileSystem->UserContext = this;
|
||||||
|
FspFileSystemSetOperationGuardStrategy(_FileSystem, Synchronized ?
|
||||||
|
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY_COARSE :
|
||||||
|
FSP_FILE_SYSTEM_OPERATION_GUARD_STRATEGY_FINE);
|
||||||
|
FspFileSystemSetDebugLog(_FileSystem, DebugLog);
|
||||||
|
#endif
|
||||||
|
Result = Api.FspFileSystemSetMountPointEx(_FileSystem, MountPoint, IntPtr.Zero);
|
||||||
|
if (0 <= Result)
|
||||||
|
Result = Api.FspFileSystemStartDispatcher(_FileSystem, 0);
|
||||||
|
}
|
||||||
|
if (0 > Result && IntPtr.Zero != _FileSystem)
|
||||||
|
{
|
||||||
|
Api.FspFileSystemDelete(_FileSystem);
|
||||||
|
_FileSystem = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
public void Unmount()
|
||||||
|
{
|
||||||
|
Api.FspFileSystemStopDispatcher(_FileSystem);
|
||||||
|
Api.FspFileSystemDelete(_FileSystem);
|
||||||
|
_FileSystem = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
#if false
|
||||||
|
PWSTR MountPoint()
|
||||||
|
{
|
||||||
|
return 0 != _FileSystem ? FspFileSystemMountPoint(_FileSystem) : 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
IntPtr FileSystemHandle()
|
||||||
|
{
|
||||||
|
return _FileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
private VolumeParams _VolumeParams;
|
private VolumeParams _VolumeParams;
|
||||||
private IntPtr _FileSystem;
|
private IntPtr _FileSystem;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user