0

I'd like to load a file such that the contents are either in memory or on disk but not both. By doing a simple open, read, and delete, this should accomplish the task. But it seems that it's up to the OS to decide when to flush the delete command to hardware. In the case of linux, a call to sync() should accomplish this. In the world of Windows, the closest you can get is FlushFileBuffers(), which takes a handle. Whend deleting a file, you don't use handles, just paths. Is there a way to force Windows to flush a delete request to disk rather than queuing or caching it?

MarkP
  • 4,168
  • 10
  • 43
  • 84
  • "To flush all open files on a volume, call FlushFileBuffers with a handle to the volume." - I expect that will include file deletions. But generally speaking there isn't much point, because of the internal cache in the HDD itself. – Harry Johnston Jan 03 '17 at 23:59
  • Linux doesn't delete the file from the disk just because you fsync'd after an open+unlink. It is only that the file is not accessible for access any more via namespace access. The space would be reclaimed only after the last fd closes. – itisravi Jan 07 '17 at 00:02

0 Answers0