Readdirectorychanges not working with big file

Posted by sanky on Stack Overflow See other posts from Stack Overflow or by sanky
Published on 2011-11-27T08:19:21Z Indexed on 2011/11/27 9:51 UTC
Read the original article Hit count: 631

i was working with readdirectorychangesW till i encountered an unwanted behavior.below is short reference the way i am using my readdirectorychanges func.

The behavior is that in case a big file in GBs is copied to the watched directory i get the notification immediately and thereby i start doing my operation according to the notification i receive ,but the file IO ( copy operation is still pending) and that results in unxpected state. Can anyone please suggest a way to synchronize this operation. I want the copy operation(that gave me notification) to get completed first then i want to do my processing.

while(ReadDirectoryChangesW(
    hDir,                                 
    pBuffer,                              
    nBufSize,                             
    FALSE,                                
    FILE_NOTIFY_CHANGE_FILE_NAME,         
    &BytesReturned,
    NULL,                                  
    NULL                           
   ))
 {
 pBufferCurrent = pBuffer;

 while(pBufferCurrent)
 {
   switch(pBufferCurrent->Action)
   {
   case FILE_ACTION_ADDED: 

          break; 
        default: 
         break;
    }
       if (pBufferCurrent->NextEntryOffset)
         pBufferCurrent = (FILE_NOTIFY_INFORMATION*)(((oef_u8_t*)pBufferCurrent) + pBufferCurrent->NextEntryOffset);
      else
        pBufferCurrent = NULL;
}

© Stack Overflow or respective owner

Related posts about winapi

Related posts about readdirectorychangesw