I am using the two flags FILE_ATTRIBUTE_TEMPORARY
and FILE_FLAG_DELETE_ON_CLOSE
while creating temporary files in my C++ application.
According to this blogđź•— there shouldn't be any file being created on the disk:
It’s only temporary
Larry Osterman, April 19, 2004
To create a “temporary” file, you call CreateFile specifying
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE
in the dwFlagsAndAttributes attribute. This combination of bits acts as a hint to the filesystem that the file data should never be flushed to disk. In other words, such a file can be created, written to, and read from without the system ever touching the disk.
But in my code the file is created and written to on disk (even for 1 KB data). Can someone confirm the exact functionality of these flags, and whether the files are created on disk or not?
Later on in that same link, there is the quote:
If you exceed available memory, the memory manager will flush the file data to disk. This causes a performance hit, but your operation will succeed instead of failing.
Marking a file as temporary will tell the system it doesn't need to be on disk, but it doesn't prevent it from being put there, either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With