|
@@ -1,4 +1,4 @@
|
|
|
-/* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
|
|
+/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
|
|
*
|
|
|
* You can redistribute this program and/or modify it under the terms of
|
|
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
|
@@ -15,16 +15,27 @@ namespace SMBLibrary.Server
|
|
|
{
|
|
|
public partial class ServerResponseHelper
|
|
|
{
|
|
|
- internal static SMBCommand GetCloseResponse(SMBHeader header, CloseRequest request, StateObject state)
|
|
|
+ internal static SMBCommand GetCloseResponse(SMBHeader header, CloseRequest request, object share, StateObject state)
|
|
|
{
|
|
|
- string openedFilePath = state.GetOpenedFilePath(request.FID);
|
|
|
- if (openedFilePath == null)
|
|
|
+ OpenedFileObject openedFile = state.GetOpenedFileObject(request.FID);
|
|
|
+ if (openedFile == null)
|
|
|
{
|
|
|
header.Status = NTStatus.STATUS_SMB_BAD_FID;
|
|
|
return new ErrorResponse(CommandName.SMB_COM_CLOSE);
|
|
|
}
|
|
|
|
|
|
state.RemoveOpenedFile(request.FID);
|
|
|
+ if (openedFile.DeleteOnClose && share is FileSystemShare)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ((FileSystemShare)share).FileSystem.Delete(openedFile.Path);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ System.Diagnostics.Debug.Print("[{0}] Close: Cannot delete '{1}'", DateTime.Now.ToString("HH:mm:ss:ffff"), openedFile.Path);
|
|
|
+ }
|
|
|
+ }
|
|
|
CloseResponse response = new CloseResponse();
|
|
|
return response;
|
|
|
}
|