EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Filesize changed --> NotifyDirectoryChange

Posted: 09/17/2012 06:43:14
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16


I have a problem. I have an ecm system. This system is visualized by cbfs to the explorer. Now I "create" these virtual files with a filesize 100kb or so.
Now while reading the correct filesize after the filetransfer (triggered from readfile) I get a filesize like 102kb. How can I notify the explorer the new filesize? I tried it with:
mCbFs.NotifyDirectoryChange(fileFullName, CbFsNotifyFileAction.fanMetaDataModified, true);

but the files are still corrupt.
Posted: 09/17/2012 06:52:41
by Eugene Mayevski (Team)

Let's rephrase your description.

You tell the OS in OnEnumerateDirectory/OnGetFileInfo, that filesize is 100Kb.

Now your backend data is changed NOT via the virtual disk (right?) and data size is increased to 102Kb. You need to tell the OS that the backend data have been changed.

Is this correct?

Sincerely yours
Eugene Mayevski
Posted: 09/17/2012 07:00:18
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16

Posted: 09/17/2012 08:40:41
by Volodymyr Zinin (Team)

mCbFs.NotifyDirectoryChange(fileFullName, CbFsNotifyFileAction.fanModified, true);
where fileFullName must be started with backslash (i.e. root directory).

fanModified must be used instead of fanMetaDataModified because it's really the data modified (and then the file size changed).
Posted: 10/15/2012 05:55:15
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16

this NotifyDirectoryChange does not work with txt files and the normal editor?!?
Posted: 10/15/2012 06:19:32
by Eugene Mayevski (Team)

why not?

Sincerely yours
Eugene Mayevski
Posted: 03/07/2014 13:19:39
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 70

Hi there!

I have a question related to this problem: how should I properly handle filesize change when it was realized inside OnReadFile callback?

Consider the following situation:
1. My callback has received 100K size from the backend storage (GetFileInfo or EnumerateDirectory handler) and returned it to the system.

2. The user application (file manager) starts copying file, reading it by blocks and causing OnReadFile callbacks to be called several times.

3. At some point the OnReadFile handler "realizes" that the file size has changed, and there're 2 possible ways:
a) it can return the requested amount of data (file size increased)
b) it cannot return the requested amount of data (file size decreased)

How should I proceed in both cases?

I can call NotifyDirectoryChange(), but in case of situation (b) I still cannot return the requested data.
Should I return some 'proper' Win32 error code that will cause OS to properly handle this situation (because NotifyDirectoryChange was just called)?
Does the error code matters? Does the fact that I called NotifyDirectoryChange affects the way of handling read error by an OS?

Posted: 03/07/2014 14:12:27
by Volodymyr Zinin (Team)

In this case there is no "absolutely correct" way to resolve the problem. As a variant start to return an error from the OnReadFile callback (maybe ERROR_INVALID_HANDLE(6) is ok) and call NotifyDirectoryChange(fanModified).
Maybe it's better to call NotifyDirectoryChange outside the callbacks in order to call it synchronously and, until it hasn't been finished, continue returning ERROR_INVALID_HANDLE(6) from the callbacks for any requests passed to this file. After the NotifyDirectoryChange synchronous call is returned all of currently existing file handles are marked as invalid and any operation with these handles causes the ERROR_INVALID_HANDLE error to return without calling of the callbacks. The only successful API call for such handles is CloseHandle. Of course the OnCleanup and OnClose callbacks still will be called.



Topic viewed 3449 times

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


Back to top

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

Got it!