mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 16:33:02 -05:00
inc, dll, dotnet: FSP_FILE_SYSTEM_INTERFACE::SetDelete
This commit is contained in:
parent
75ae8daf8f
commit
24b96e7e1b
@ -384,6 +384,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
|||||||
* @see
|
* @see
|
||||||
* Close
|
* Close
|
||||||
* CanDelete
|
* CanDelete
|
||||||
|
* SetDelete
|
||||||
*/
|
*/
|
||||||
VOID (*Cleanup)(FSP_FILE_SYSTEM *FileSystem,
|
VOID (*Cleanup)(FSP_FILE_SYSTEM *FileSystem,
|
||||||
PVOID FileContext, PWSTR FileName, ULONG Flags);
|
PVOID FileContext, PWSTR FileName, ULONG Flags);
|
||||||
@ -567,6 +568,9 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
|||||||
* This function gets called when Win32 API's such as DeleteFile or RemoveDirectory are used.
|
* This function gets called when Win32 API's such as DeleteFile or RemoveDirectory are used.
|
||||||
* It does not get called when a file or directory is opened with FILE_DELETE_ON_CLOSE.
|
* It does not get called when a file or directory is opened with FILE_DELETE_ON_CLOSE.
|
||||||
*
|
*
|
||||||
|
* NOTE: If both CanDelete and SetDelete are defined, SetDelete takes precedence. However
|
||||||
|
* most file systems need only implement the CanDelete operation.
|
||||||
|
*
|
||||||
* @param FileSystem
|
* @param FileSystem
|
||||||
* The file system on which this request is posted.
|
* The file system on which this request is posted.
|
||||||
* @param FileContext
|
* @param FileContext
|
||||||
@ -577,6 +581,7 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
|||||||
* STATUS_SUCCESS or error code.
|
* STATUS_SUCCESS or error code.
|
||||||
* @see
|
* @see
|
||||||
* Cleanup
|
* Cleanup
|
||||||
|
* SetDelete
|
||||||
*/
|
*/
|
||||||
NTSTATUS (*CanDelete)(FSP_FILE_SYSTEM *FileSystem,
|
NTSTATUS (*CanDelete)(FSP_FILE_SYSTEM *FileSystem,
|
||||||
PVOID FileContext, PWSTR FileName);
|
PVOID FileContext, PWSTR FileName);
|
||||||
@ -855,12 +860,46 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
|
|||||||
PVOID FileContext, UINT32 ControlCode,
|
PVOID FileContext, UINT32 ControlCode,
|
||||||
PVOID InputBuffer, ULONG InputBufferLength,
|
PVOID InputBuffer, ULONG InputBufferLength,
|
||||||
PVOID OutputBuffer, ULONG OutputBufferLength, PULONG PBytesTransferred);
|
PVOID OutputBuffer, ULONG OutputBufferLength, PULONG PBytesTransferred);
|
||||||
|
/**
|
||||||
|
* Set the file delete flag.
|
||||||
|
*
|
||||||
|
* This function sets a flag to indicates whether the FSD file should delete a file
|
||||||
|
* when it is closed. This function does not need to perform access checks, but may
|
||||||
|
* performs tasks such as check for empty directories, etc.
|
||||||
|
*
|
||||||
|
* This function should <b>NEVER</b> delete the file or directory in question. Deletion should
|
||||||
|
* happen during Cleanup with the FspCleanupDelete flag set.
|
||||||
|
*
|
||||||
|
* This function gets called when Win32 API's such as DeleteFile or RemoveDirectory are used.
|
||||||
|
* It does not get called when a file or directory is opened with FILE_DELETE_ON_CLOSE.
|
||||||
|
*
|
||||||
|
* NOTE: If both CanDelete and SetDelete are defined, SetDelete takes precedence. However
|
||||||
|
* most file systems need only implement the CanDelete operation.
|
||||||
|
*
|
||||||
|
* @param FileSystem
|
||||||
|
* The file system on which this request is posted.
|
||||||
|
* @param FileContext
|
||||||
|
* The file context of the file or directory to set the delete flag for.
|
||||||
|
* @param FileName
|
||||||
|
* The name of the file or directory to set the delete flag for.
|
||||||
|
* @param DeleteFile
|
||||||
|
* If set to TRUE the FSD indicates that the file will be deleted on Cleanup; otherwise
|
||||||
|
* it will not be deleted. It is legal to receive multiple SetDelete calls for the same
|
||||||
|
* file with different DeleteFile parameters.
|
||||||
|
* @return
|
||||||
|
* STATUS_SUCCESS or error code.
|
||||||
|
* @see
|
||||||
|
* Cleanup
|
||||||
|
* CanDelete
|
||||||
|
*/
|
||||||
|
NTSTATUS (*SetDelete)(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
PVOID FileContext, PWSTR FileName, BOOLEAN DeleteFile);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This ensures that this interface will always contain 64 function pointers.
|
* This ensures that this interface will always contain 64 function pointers.
|
||||||
* Please update when changing the interface as it is important for future compatibility.
|
* Please update when changing the interface as it is important for future compatibility.
|
||||||
*/
|
*/
|
||||||
NTSTATUS (*Reserved[38])();
|
NTSTATUS (*Reserved[37])();
|
||||||
} FSP_FILE_SYSTEM_INTERFACE;
|
} FSP_FILE_SYSTEM_INTERFACE;
|
||||||
FSP_FSCTL_STATIC_ASSERT(sizeof(FSP_FILE_SYSTEM_INTERFACE) == 64 * sizeof(NTSTATUS (*)()),
|
FSP_FSCTL_STATIC_ASSERT(sizeof(FSP_FILE_SYSTEM_INTERFACE) == 64 * sizeof(NTSTATUS (*)()),
|
||||||
"FSP_FILE_SYSTEM_INTERFACE must have 64 entries.");
|
"FSP_FILE_SYSTEM_INTERFACE must have 64 entries.");
|
||||||
|
@ -1047,13 +1047,22 @@ FSP_API NTSTATUS FspFileSystemOpSetInformation(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 != FileSystem->Interface->CanDelete)
|
if (0 != FileSystem->Interface->SetDelete)
|
||||||
|
{
|
||||||
|
Result = FileSystem->Interface->SetDelete(FileSystem,
|
||||||
|
(PVOID)ValOfFileContext(Request->Req.SetInformation),
|
||||||
|
(PWSTR)Request->Buffer,
|
||||||
|
Request->Req.SetInformation.Info.Disposition.Delete);
|
||||||
|
}
|
||||||
|
else if (0 != FileSystem->Interface->CanDelete)
|
||||||
|
{
|
||||||
if (Request->Req.SetInformation.Info.Disposition.Delete)
|
if (Request->Req.SetInformation.Info.Disposition.Delete)
|
||||||
Result = FileSystem->Interface->CanDelete(FileSystem,
|
Result = FileSystem->Interface->CanDelete(FileSystem,
|
||||||
(PVOID)ValOfFileContext(Request->Req.SetInformation),
|
(PVOID)ValOfFileContext(Request->Req.SetInformation),
|
||||||
(PWSTR)Request->Buffer);
|
(PWSTR)Request->Buffer);
|
||||||
else
|
else
|
||||||
Result = STATUS_SUCCESS;
|
Result = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 10/*FileRenameInformation*/:
|
case 10/*FileRenameInformation*/:
|
||||||
if (0 != FileSystem->Interface->Rename)
|
if (0 != FileSystem->Interface->Rename)
|
||||||
|
@ -341,6 +341,7 @@ namespace Fsp
|
|||||||
/// These flags determine whether the file was modified and whether to delete the file.
|
/// These flags determine whether the file was modified and whether to delete the file.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <seealso cref="CanDelete"/>
|
/// <seealso cref="CanDelete"/>
|
||||||
|
/// <seealso cref="SetDelete"/>
|
||||||
/// <seealso cref="Close"/>
|
/// <seealso cref="Close"/>
|
||||||
public virtual void Cleanup(
|
public virtual void Cleanup(
|
||||||
Object FileNode,
|
Object FileNode,
|
||||||
@ -595,6 +596,22 @@ namespace Fsp
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether a file or directory can be deleted.
|
/// Determines whether a file or directory can be deleted.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This function tests whether a file or directory can be safely deleted. This function does
|
||||||
|
/// not need to perform access checks, but may performs tasks such as check for empty
|
||||||
|
/// directories, etc.
|
||||||
|
/// </para><para>
|
||||||
|
/// This function should <b>NEVER</b> delete the file or directory in question. Deletion should
|
||||||
|
/// happen during Cleanup with the FspCleanupDelete flag set.
|
||||||
|
/// </para><para>
|
||||||
|
/// This function gets called when Win32 API's such as DeleteFile or RemoveDirectory are used.
|
||||||
|
/// It does not get called when a file or directory is opened with FILE_DELETE_ON_CLOSE.
|
||||||
|
/// </para><para>
|
||||||
|
/// NOTE: If both CanDelete and SetDelete are defined, SetDelete takes precedence. However
|
||||||
|
/// most file systems need only implement the CanDelete operation.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
/// <param name="FileNode">
|
/// <param name="FileNode">
|
||||||
/// The file node of the file or directory to test for deletion.
|
/// The file node of the file or directory to test for deletion.
|
||||||
/// </param>
|
/// </param>
|
||||||
@ -606,6 +623,7 @@ namespace Fsp
|
|||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>STATUS_SUCCESS or error code.</returns>
|
/// <returns>STATUS_SUCCESS or error code.</returns>
|
||||||
/// <seealso cref="Cleanup"/>
|
/// <seealso cref="Cleanup"/>
|
||||||
|
/// <seealso cref="SetDelete"/>
|
||||||
public virtual Int32 CanDelete(
|
public virtual Int32 CanDelete(
|
||||||
Object FileNode,
|
Object FileNode,
|
||||||
Object FileDesc,
|
Object FileDesc,
|
||||||
@ -1013,6 +1031,50 @@ namespace Fsp
|
|||||||
BytesTransferred = default(UInt32);
|
BytesTransferred = default(UInt32);
|
||||||
return STATUS_INVALID_DEVICE_REQUEST;
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the file delete flag.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This function sets a flag to indicates whether the FSD file should delete a file
|
||||||
|
/// when it is closed. This function does not need to perform access checks, but may
|
||||||
|
/// performs tasks such as check for empty directories, etc.
|
||||||
|
/// </para><para>
|
||||||
|
/// This function should <b>NEVER</b> delete the file or directory in question. Deletion should
|
||||||
|
/// happen during Cleanup with the FspCleanupDelete flag set.
|
||||||
|
/// </para><para>
|
||||||
|
/// This function gets called when Win32 API's such as DeleteFile or RemoveDirectory are used.
|
||||||
|
/// It does not get called when a file or directory is opened with FILE_DELETE_ON_CLOSE.
|
||||||
|
/// </para><para>
|
||||||
|
/// NOTE: If both CanDelete and SetDelete are defined, SetDelete takes precedence. However
|
||||||
|
/// most file systems need only implement the CanDelete operation.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="FileNode">
|
||||||
|
/// The file node of the file or directory to set the delete flag for.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="FileDesc">
|
||||||
|
/// The file descriptor of the file or directory to set the delete flag for.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="FileName">
|
||||||
|
/// The name of the file or directory to set the delete flag for.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="DeleteFile">
|
||||||
|
/// If set to TRUE the FSD indicates that the file will be deleted on Cleanup; otherwise
|
||||||
|
/// it will not be deleted. It is legal to receive multiple SetDelete calls for the same
|
||||||
|
/// file with different DeleteFile parameters.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>STATUS_SUCCESS or error code.</returns>
|
||||||
|
/// <seealso cref="Cleanup"/>
|
||||||
|
/// <seealso cref="CanDelete"/>
|
||||||
|
public virtual Int32 SetDelete(
|
||||||
|
Object FileNode,
|
||||||
|
Object FileDesc,
|
||||||
|
String FileName,
|
||||||
|
Boolean DeleteFile)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
/* helpers */
|
/* helpers */
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1065,6 +1065,28 @@ namespace Fsp
|
|||||||
return ExceptionHandler(FileSystem, ex);
|
return ExceptionHandler(FileSystem, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static Int32 SetDelete(
|
||||||
|
IntPtr FileSystemPtr,
|
||||||
|
ref FullContext FullContext,
|
||||||
|
String FileName,
|
||||||
|
Boolean DeleteFile)
|
||||||
|
{
|
||||||
|
FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Object FileNode, FileDesc;
|
||||||
|
Api.GetFullContext(ref FullContext, out FileNode, out FileDesc);
|
||||||
|
return FileSystem.SetDelete(
|
||||||
|
FileNode,
|
||||||
|
FileDesc,
|
||||||
|
FileName,
|
||||||
|
DeleteFile);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ExceptionHandler(FileSystem, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static FileSystemHost()
|
static FileSystemHost()
|
||||||
{
|
{
|
||||||
@ -1094,6 +1116,7 @@ namespace Fsp
|
|||||||
_FileSystemInterface.GetStreamInfo = GetStreamInfo;
|
_FileSystemInterface.GetStreamInfo = GetStreamInfo;
|
||||||
_FileSystemInterface.GetDirInfoByName = GetDirInfoByName;
|
_FileSystemInterface.GetDirInfoByName = GetDirInfoByName;
|
||||||
_FileSystemInterface.Control = Control;
|
_FileSystemInterface.Control = Control;
|
||||||
|
_FileSystemInterface.SetDelete = SetDelete;
|
||||||
|
|
||||||
_FileSystemInterfacePtr = Marshal.AllocHGlobal(FileSystemInterface.Size);
|
_FileSystemInterfacePtr = Marshal.AllocHGlobal(FileSystemInterface.Size);
|
||||||
Marshal.StructureToPtr(_FileSystemInterface, _FileSystemInterfacePtr, false);
|
Marshal.StructureToPtr(_FileSystemInterface, _FileSystemInterfacePtr, false);
|
||||||
|
@ -470,6 +470,11 @@ namespace Fsp.Interop
|
|||||||
IntPtr InputBuffer, UInt32 InputBufferLength,
|
IntPtr InputBuffer, UInt32 InputBufferLength,
|
||||||
IntPtr OutputBuffer, UInt32 OutputBufferLength,
|
IntPtr OutputBuffer, UInt32 OutputBufferLength,
|
||||||
out UInt32 PBytesTransferred);
|
out UInt32 PBytesTransferred);
|
||||||
|
internal delegate Int32 SetDelete(
|
||||||
|
IntPtr FileSystem,
|
||||||
|
ref FullContext FullContext,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)] String FileName,
|
||||||
|
[MarshalAs(UnmanagedType.U1)] Boolean DeleteFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int Size = IntPtr.Size * 64;
|
internal static int Size = IntPtr.Size * 64;
|
||||||
@ -500,7 +505,8 @@ namespace Fsp.Interop
|
|||||||
internal Proto.GetStreamInfo GetStreamInfo;
|
internal Proto.GetStreamInfo GetStreamInfo;
|
||||||
internal Proto.GetDirInfoByName GetDirInfoByName;
|
internal Proto.GetDirInfoByName GetDirInfoByName;
|
||||||
internal Proto.Control Control;
|
internal Proto.Control Control;
|
||||||
/* NTSTATUS (*Reserved[38])(); */
|
internal Proto.SetDelete SetDelete;
|
||||||
|
/* NTSTATUS (*Reserved[37])(); */
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user