Mail Archives: djgpp/2001/08/27/00:34:25
hello,
i would like to write a program that will watch a given directory (possibly
one that it was started in) for any file creation/deletion operations.
I can do this in Windows using the code snippet included at the bottom of
this post. However, I would like to use djgpp. I am assuming there is no
similar API in the libraries, and hence I should chain some DOS interrupts.
(I could sit in a tight loop reading directory contents but I could miss
some creations/deletions if they happen rapidly).
Anyway, I do not know where to begin so I would appreciate any pointers.
Which DOS interrupt/API should I look for? Any hints?
Thanks
Sinan.
==== Win32 example ====
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main(void)
{
DWORD wait_ret_code = 0;
HANDLE h = INVALID_HANDLE_VALUE;
h = FindFirstChangeNotification(".",
FALSE,
FILE_NOTIFY_CHANGE_SIZE |
FILE_NOTIFY_CHANGE_LAST_WRITE);
if( h == INVALID_HANDLE_VALUE )
{
fprintf(stderr, "Invalid handle registering for
notification\n");
exit(EXIT_FAILURE);
}
wait_ret_code = WaitForSingleObject(h, INFINITE);
if( wait_ret_code == WAIT_FAILED )
{
fprintf(stderr, "Wait failed\n");
exit(EXIT_FAILURE);
}
if( wait_ret_code == WAIT_OBJECT_0 )
{
fprintf(stderr, "Change notification received ...\n");
}
return 0;
}
--
--------------------------------
A. Sinan Unur
http://www.unur.com/
- Raw text -