is there a way to remove FILE_FLAG_DELETE_ON_CLOSE?
in my app I'd like to open a temp file with FILE_FLAG_DELETE_ON_CLOSE. however there are some cases where the temp file needs to be kept and is quite large
I'd like to remove the FILE_FLAG_DELETE_ON_CLOSE attribute on an opened handle开发者_StackOverflow? is this possible? copying the contents of the file or renaming isnt quite what I want, I'd like to remove the attribute. this is due to how i'm transacting some writes, in my app closing the handle will open me up to a race condition
You could do it the other way around.
Open the file first, specifying FILE_SHARE_DELETE
.
Then, when you need to close the file, open it again with FILE_DELETE_ON_CLOSE
, then close both handles. Or, just close it, and it won't be deleted.
No, it's not possible once you've done the create. A dangerous idea might start with the statement, "That flag is only relevant to the handle the link was opened on." So creating a new link might "fix" it. I haven't thought about that more than five seconds, but it's the only slightly clever thing coming to me at midnight.
精彩评论