From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: file system change notification Date: 26 Aug 2001 22:01:11 GMT Organization: Cornell University Lines: 60 Sender: asu1 AT cornell DOT invalid (on slip-32-102-40-95.ny.us.prserv.net) Message-ID: NNTP-Posting-Host: slip-32-102-40-95.ny.us.prserv.net X-Trace: news01.cit.cornell.edu 998863271 25908 32.102.40.95 (26 Aug 2001 22:01:11 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 26 Aug 2001 22:01:11 GMT User-Agent: Xnews/4.06.22 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 #include #include 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/