Advertisement

Linux programming question (filesystem)...

Started by February 28, 2001 12:54 AM
6 comments, last by Dire.Wolf 23 years, 6 months ago
Does anyone know if Linux has an API command equivalent to the Win32 API function, FindFirstChangeNotification()? If you know the answer can you please post a very small sample of code that demonstrates the Linux equivalent to the following Win32 code:
  
HANDLE filewatch = 
FindFirstChangeNotification(_T("c:\\"),
                            FALSE,
                            FILE_NOTIFY_CHANGE_FILE_NAME);
DWORD waitresult = WaitForSingleObject(filewatch, INFINITE);
switch(waitresult)
{
    case WAIT_OBJECT_0:
        // do something

        FindNextChangeNotification(filewatch);
        break;
}

  
Thanks in advance! Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
Is Linux not advanced enough to support this?



Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
Advertisement
quote:
Original post by Dire.Wolf
Is Linux not advanced enough to support this?




You''re sure to get someone to flame you if nothing else like that, heh . Maybe you should look into how that function works (I''m not sure myself) and make a clone of it. I''m sure Linux can do it, but I''m not sure if it is built it. Good luck .

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!
http://www.gdarchive.net/druidgames/
What does the function exactly do ? I don''t have much knowledge of vc++.

If it has to notify of changes in a file, look into timestamps in linux.
Hello from my world
The whole reason I said that was to get some responses

I don''t want to use timestamps and have to keep polling a directory. Doesn''t Linux support kernel event objects? Using an event object and calling an OS API that waits on the object allows the OS not to schedule the thread. Polling eats CPU cycles and can hurt performance.

Linux MUST have some sort of synchronization primitives?



Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
AFAIK Linux can''t do that yet, as I''ve recently read in a KDE discussion. However, you can be almost certain that somebody''s working on it. I don''t know how hard it would be to implement. Does FindFirstChangeNotification() trigger on any file change below the directory you specify? If so, the implementation could get quite difficult.

cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy
Advertisement
AFAIK Linux can''t do that yet, as I''ve recently read in a KDE discussion. However, you can be almost certain that somebody''s working on it. I don''t know how hard it would be to implement. Does FindFirstChangeNotification() trigger on any file change below the directory you specify? If so, the implementation could get quite difficult.

cu,
Prefect

One line of sourcecode says more than a thousand words.
Widelands - laid back, free software strategy
Prefect,

Yes it does but only if you ask FindFirstChangeNotification to include subdirectories. The pain in the butt with FindFirstChangeNotification is that it doesn''t tell you *which* files changed or how. Most of the time you take a snapshot of the directory (or subdirectories) and then when the change happens you take another snapshot and compare the two. There are subtle issues with this technique but it works well enough.

Best regards,


Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com

This topic is closed to new replies.

Advertisement