readdirectorychangesw

Why is GetOverlappedResult giving 0 bytes result for ReadDirectoryChangesW?

荒凉一梦 提交于 2020-03-05 05:08:06
问题 I have written a file system watcher for our project. Suddenly, it stopped getting events properly. I found out, that after GetOverlappedResult returns true, the result data are empty and so is bytes returned. This is how I create file handle for watching a directory: _directoryHandle = ::CreateFileA("some path", FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); This is how I start

ReadDirectoryChangesW only places single event in the FILE_NOTIFY_INFORMATION buffer

血红的双手。 提交于 2020-01-25 06:56:06
问题 I have a problem that ReadDirectoryChangesW keeps missing events. I did a lot of googling and the bellow function arguments seem correct according to my searches, but nobody knows for certain. I start watching like this. BOOL _watchRequestResult = false; OVERLAPPED _ovl = { 0 }; _ovl.hEvent = ::CreateEventA(NULL, TRUE, FALSE, NULL); _directoryHandle = ::CreateFileA("some path here", FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG

Using ReadDirectoryChangesW asynchronously in a loop

我的未来我决定 提交于 2019-12-23 02:16:39
问题 INTRODUCTION: I am trying to use ReadDirectoryChangesW asynchronously in a loop. Below snippet illustrates what I am trying to achieve: DWORD example() { DWORD error = 0; OVERLAPPED ovl = { 0 }; ovl.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); if (NULL == ovl.hEvent) return ::GetLastError(); char buffer[1024]; while(1) { process_list_of_existing_files(); error = ::ReadDirectoryChangesW( m_hDirectory, // I have added FILE_FLAG_OVERLAPPED in CreateFile buffer, sizeof(buffer), FALSE, FILE

ReadDirectoryChangesW blocks deleting the watched directory

你离开我真会死。 提交于 2019-12-22 08:16:29
问题 I am trying to watch a directory for create/delete/rename changes on windows with python using the ReadDirectoryChangesW API. This is my code and it is working fine: results = win32file.ReadDirectoryChangesW(self.hDir, 8192, True, self.type, None, None) for action, file in results: full_filename = os.path.join (self.source_path, file) if action == 1: # Created self.fileCreated(full_filename) elif action == 2: # Deleted self.fileDeleted(full_filename) elif action == 3: # Updated self

How to use ReadDirectoryChangesW() method with completion routine?

会有一股神秘感。 提交于 2019-12-18 15:29:22
问题 I want to use function ReadDirectoryChangesW() in asynchronous mode with I/O completion routine supplied. The question is I don't know how to retrieve the exact information about the change in the completion routine (a CALLBACK function). Completion routine is defined like this: VOID CALLBACK FileIOCompletionRoutine( [in] DWORD dwErrorCode, [in] DWORD dwNumberOfBytesTransfered, [in] LPOVERLAPPED lpOverlapped ); I wonder the information is included in the LPOVERLAPPED structure. But I don't

How to keep ReadDirectoryChangesW from missing file changes

烈酒焚心 提交于 2019-12-18 11:46:02
问题 There are many posts on the internet about the ReadDirectoryChangesW API function missing files when there is a lot of file activity. Most blame the speed at which the ReadDirectoryChangesW function loop is called. This is an incorrect assumption. The best explanation I have seen is in the following post, the comment on Monday, April 14, 2008 2:15:27 PM http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4465cafb-f4ed-434f-89d8-c85ced6ffaa8/ The summary is that the

CreateFile ,ReadDirectoryChanges issue

纵饮孤独 提交于 2019-12-11 05:56:23
问题 I’m using ReadDirectoryChangesW to spy a folder that I opened with CreateFile , once a file was added I call a function ( OnFileChanged ) that read the size and open it for reading, my application works fine for small sized file but the problem occurs when I try to copy a big file into my folder(7,24 M), and I get Permission denied error after calling fopen to read it. the watching process is based on this void Init(const QString FullPath) { ... hDir = CreateFile( dirPath, // pointer to the

ReadDirectoryChangesW blocks deleting the watched directory

二次信任 提交于 2019-12-05 17:51:27
I am trying to watch a directory for create/delete/rename changes on windows with python using the ReadDirectoryChangesW API. This is my code and it is working fine: results = win32file.ReadDirectoryChangesW(self.hDir, 8192, True, self.type, None, None) for action, file in results: full_filename = os.path.join (self.source_path, file) if action == 1: # Created self.fileCreated(full_filename) elif action == 2: # Deleted self.fileDeleted(full_filename) elif action == 3: # Updated self.fileUpdated(full_filename) elif action == 4: # Renamed from something renamed_file = full_filename elif action =

File-level filesystem change notification in Mac OS X

青春壹個敷衍的年華 提交于 2019-12-03 04:48:14
问题 I want my code to be notified when any file under (either directly or indirectly) a given directory is modified. By "modified", I mean I want my code to be notified whenever a file's contents are altered, it's renamed, or it's deleted; or if a new file is added. For my application, there can be thousands of files. I looked as FSEvents, but its Technology Overview says, in part: The important point to take away is that the granularity of notifications is at a directory level. It tells you only

File-level filesystem change notification in Mac OS X

自闭症网瘾萝莉.ら 提交于 2019-12-02 19:08:44
I want my code to be notified when any file under (either directly or indirectly) a given directory is modified. By "modified", I mean I want my code to be notified whenever a file's contents are altered, it's renamed, or it's deleted; or if a new file is added. For my application, there can be thousands of files. I looked as FSEvents, but its Technology Overview says, in part: The important point to take away is that the granularity of notifications is at a directory level. It tells you only that something in the directory has changed, but does not tell you what changed. It also says: The