EldoS | Feel safer!

Software components for data protection, secure storage and transfer

NotifyDirectoryChange for the root folder?

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#11014
Posted: 09/10/2009 16:48:18
by Kurt Griffiths (Standard support level)
Joined: 12/08/2008
Posts: 34

NotifyDirectoryChange does not seem to cause Windows Explorer to refresh the root directory when a file has been renamed, but this technique works fine for subdirectories.

I'm passing in "\" and CallbackFileSystem::fanModified for the parameters.

Am I missing something?
#11017
Posted: 09/11/2009 00:51:30
by Volodymyr Zinin (EldoS Corp.)

It's necessary to call NotifyDirectoryChange for every modified file. I.e. if for example a file "\qwerty.txt" has been renamed then call NotifyDirectoryChange("\qwerty.txt", CallbackFileSystem::fanModified).
And don't forget that this function should be used only if files/directories are modified outside CallbackFS.
#11027
Posted: 09/11/2009 10:21:27
by Kurt Griffiths (Standard support level)
Joined: 12/08/2008
Posts: 34

Thanks for the info. I am indeed doing this because files are modified outside CallbackFS. After further testing, it seems my problem is limited to Windows 7. I know that Windows 7 will not be officially supported until CallbackFS 3.0, but I would like to provide some details about what I've observed so that it can be taken into consideration for 3.0.

Here are the calls I am making in the given order:

NotifyDirectoryChange("\foo\oldName.txt", CallbackFileSystem::fanRemoved)
NotifyDirectoryChange("\foo\newName.txt", CallbackFileSystem::fanAdded)
NotifyDirectoryChange("\foo", CallbackFileSystem::fanModified)

I added the last call, since without it Windows Explorer does not remove oldName.txt from the view. The fanRemoved doesn't seem be propagating to Windows correctly. If I spy on file change notifications via the Win32 function ReadDirectoryChangesW, there is never a FILE_ACTION_REMOVED that comes through.

However, when I try the same thing in the root folder (see below), my workaround does not help. In this case, the only file change notification that makes it through is a FILE_ACTION_ADDED for newName.txt.

NotifyDirectoryChange("\oldName.txt", CallbackFileSystem::fanRemoved)
NotifyDirectoryChange("\newName.txt", CallbackFileSystem::fanAdded)
NotifyDirectoryChange("\", CallbackFileSystem::fanModified)

I also tried sending fanModified instead of fanRemoved, but it made no difference.

So, I have two problems here:

1. CallbackFileSystem::fanModified does not work on the root directory, so I can't use that as a workaround.
2. CallbackFileSystem::fanRemoved and CallbackFileSystem::fanModified never work when applied to a file (at least, I never see the resulting change notifications).

Note that on Windows XP/Vista, Explorer does actually refresh correctly, even if I do not call NotifyDirectoryChange("\", CallbackFileSystem::fanModified). That being said, the only file change notification that the I/O system propagates is FILE_ACTION_ADDED. Is that by design, or am I missing something here?
#11032
Posted: 09/11/2009 16:02:29
by Kurt Griffiths (Standard support level)
Joined: 12/08/2008
Posts: 34

It looks like I spoke too soon... I discovered that I was passing "/oldName.txt" instead of "\oldName.txt". When I fixed the slash character, FILE_ACTION_REMOVE started coming though and everything works much better on Windows 7.

However, it is still interesting to note that CallbackFileSystem::fanModified does not have an affect on the root directory, and that Windows XP/Vista do *not* require the CallbackFileSystem::fanRemoved call to trigger a refresh.
#11038
Posted: 09/14/2009 01:33:35
by Volodymyr Zinin (EldoS Corp.)

It isn't necessary to call NotifyDirectoryChange with fanModified for the parent directory after some files in it have been modified. You need to call it for a directory only if the directory itself has been changed (for example either it was renamed or its modification time was changed).
But for the the root directory - this is a special directory that can't be changed (i.e. renamed, etc). So it's correct that NotifyDirectoryChange doesn't affect it.
#19801
Posted: 04/16/2012 09:45:04
by Thorsten Schenkel (Basic support level)
Joined: 04/16/2012
Posts: 1

At the moment our implementation of the IVirtualDrive and the ICbfsHandler fires NotifyDirectoryChange for every change in the connected database. Also for changes that are triggered from the CallbackFS. But this seems not be correct. In the post of 09/11/2009 07:51:30 is mentioned that the function NotifyDirectoryChange should only be used outside CallbackFS. What does outside mean? Outside a thread? ...
#19802
Posted: 04/16/2012 10:08:08
by Volodymyr Zinin (EldoS Corp.)

NotifyDirectoryChange is implemented to report CallbackFS about changes occurred outside CallbackFS. For example you use CallbackFS to represent files on some remote machine and in parallel there can be access to these files fr om some third party application located somewh ere in the internet and this application modifies the files. Of course CallbackFS doesn't know about such modifications and by the use of NotifyDirectoryChange you can notify CallbackFS about them.
NotifyDirectoryChange can be called inside as well as outside the callbacks.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 2250 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!