Readdirectorychanges not working with big file
- by sanky
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;
}