-
Notifications
You must be signed in to change notification settings - Fork 223
Open
Description
I'm trying to build an abstraction where a function can return a handle from either createfile or cfopenfilewithoplock, e.g.
public static HFILE GetHandle(string filePath)
{
if (File.Exists(filePath))
{
return Kernel32.CreateFile(filePath, 0, 0, dwCreationDisposition: FileMode.Open, dwFlagsAndAttributes: FileFlagsAndAttributes.FILE_ATTRIBUTE_NORMAL);
}
else if (Directory.Exists(filePath))
{
CfOpenFileWithOplock(filePath, CF_OPEN_FILE_FLAGS.CF_OPEN_FILE_FLAG_NONE, out var protectedHandle);
return protectedHandle;
}
return HFILE.INVALID_HANDLE_VALUE;
}
Both of these functions return safe___ file objects, so if it were possible to change the return type of the function to be a common type I could then dispose of it more neatly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels