dll: dotnet: revert the Delete redesign

This commit is contained in:
Bill Zissimopoulos
2021-11-22 13:55:32 +00:00
parent a9d90acd71
commit 826a514fe3
6 changed files with 54 additions and 177 deletions

View File

@ -564,6 +564,19 @@ namespace memfs
AllocationUnit * AllocationUnit;
SetFileSizeInternal(FileNode, AllocationSize, true);
}
if (0 != (Flags & CleanupDelete) && !FileNodeMap.HasChild(FileNode))
{
List<String> StreamFileNames = new List<String>(FileNodeMap.GetStreamFileNames(FileNode));
foreach (String StreamFileName in StreamFileNames)
{
FileNode StreamNode = FileNodeMap.Get(StreamFileName);
if (null == StreamNode)
continue; /* should not happen */
FileNodeMap.Remove(StreamNode);
}
FileNodeMap.Remove(FileNode);
}
}
public override void Close(
@ -908,6 +921,19 @@ namespace memfs
return STATUS_SUCCESS;
}
public override Int32 CanDelete(
Object FileNode0,
Object FileDesc,
String FileName)
{
FileNode FileNode = (FileNode)FileNode0;
if (FileNodeMap.HasChild(FileNode))
return STATUS_DIRECTORY_NOT_EMPTY;
return STATUS_SUCCESS;
}
public override Int32 Rename(
Object FileNode0,
Object FileDesc,
@ -1305,45 +1331,6 @@ namespace memfs
FileNode.FileInfo.EaSize = FileNode.FileInfo.EaSize + EaSizePlus - EaSizeMinus;
return STATUS_SUCCESS;
}
public override Int32 Delete(
Object FileNode0,
Object FileDesc,
String FileName,
UInt32 Flags)
{
FileNode FileNode = (FileNode)FileNode0;
switch (Flags)
{
case FILE_DISPOSITION_DO_NOT_DELETE:
return STATUS_SUCCESS;
case FILE_DISPOSITION_DELETE:
if (FileNodeMap.HasChild(FileNode))
return STATUS_DIRECTORY_NOT_EMPTY;
return STATUS_SUCCESS;
case FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS:
case ~(UInt32)0:
if (FileNodeMap.HasChild(FileNode))
return STATUS_DIRECTORY_NOT_EMPTY;
List<String> StreamFileNames = new List<String>(FileNodeMap.GetStreamFileNames(FileNode));
foreach (String StreamFileName in StreamFileNames)
{
FileNode StreamNode = FileNodeMap.Get(StreamFileName);
if (null == StreamNode)
continue; /* should not happen */
FileNodeMap.Remove(StreamNode);
}
FileNodeMap.Remove(FileNode);
return STATUS_SUCCESS;
default:
return STATUS_INVALID_PARAMETER;
}
}
private FileNodeMap FileNodeMap;
private UInt32 MaxFileNodes;