Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was wondering if there is some way to determine when a file finishes writing to a directory on both Windows and Linux (obviously, they will probably be two different commands).

This is mostly so that, instead of constantly polling a directory for new non-temp files, I can set up a program to simply listen for the completion of a write-to-disk (it seems better to do things that way).

share|improve this question

3 Answers 3

up vote 2 down vote accepted
  1. Files don't "write to directories". Data are written to files, and files may be (hard) linked into directories. But the data writing process to the file has nothing to do with the directory; and the hard linking process is atomic and has no "finish" to wait for.
  2. On Windows, the function that you are looking for is FindFirstChangeNotification().
  3. This is a StackOverflow topic, not a SuperUser one.
share|improve this answer
    
It was a tad ambiguous. On the one hand, I'm looking for a way to hook into the kernel, and often Linux will give you hooks to do this type of thing from the command line. There may have also been a Windows API for the same thing. –  cwallenpoole Jul 19 '11 at 13:13

For linux, you can take a look at this question, the discussion was in c++ but the idea (from the answers, not jsut the choosen one) are still good. Basically, in linux you can use some flags, or watch the /proc/pid/fd process.

share|improve this answer

Windows at least since Vista there is an I/O scheduling system:

I/O Prioritization in Windows Vista.

Additionally also modern SATA disks in AHCI mode have their own integrated scheduler - called Native Command Queuing (NCQ).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.