EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Mapper sample problem

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#22868
Posted: 12/18/2012 08:29:39
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Hello, i've a problem with mapper sample.

In my test root path is 'C:\' and mounting point is 'Z:'.

This is the list of my test's operation :
1 - create a new file (MyDocument.txt) in Z;
2 - open 'Z:\MyDocument.txt', write on something and save (file size 20 bytes);
3 - open 'C:\MyDocument.txt', write on something (append test) and save (file size 35 bytes);
4 - open 'Z:\MyDocument.txt'.

At point 4, when open 'Z:\MyDocument.txt' OnEnumerateDirectory event read the right size of file (35 bytes) and other attributes (like LastWriteTime) but when i open it OnReadFile event read always a file of 20 bytes and it doesn't recognize that it was modified externally.

Can anyone help me?
#22883
Posted: 12/18/2012 09:56:42
by Volodymyr Zinin (EldoS Corp.)

CallbackFS knows nothing about the file modification in the step 3. If you want to use such scenario use the NotifyDirectoryChange method to notify CallbackFS about the modification.
The reason of the problem is that the first data (20 byte) is cached by the system and the system considers that the files 'C:\MyDocument.txt' and 'Z:\MyDocument.txt' are different. It doesn't know that CallbackFS "maps" one file to the other.
#22885
Posted: 12/18/2012 10:16:31
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Thank you Vladimir.
To solve the problem, in which event I have to use NotifyDirectoryChange method?

Thanks in advance,
Davide
#22887
Posted: 12/18/2012 10:47:43
by Volodymyr Zinin (EldoS Corp.)

It's better to use NotifyDirectoryChange not in the callbacks but in some mechanism implemented by you, which tracks for the "backend" changes and notifies CallbackFS about them.

For example the backend of your CallbackFS implementation is some files (or database records) that are located on a remote server. So the callbacks are used to represent these files and in addition you create a separate thread which in cycle tracks for changes which are made by other code (other than your implementation of the callbacks) and calls NotifyDirectoryChange.
#22888
Posted: 12/18/2012 11:09:03
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

So I can't resolve problem in Mapper sample?

If I add a button in Mapper sample, that call NotifyDirectoryChange, can I solve the problem?
#22892
Posted: 12/18/2012 12:30:46
by Eugene Mayevski (EldoS Corp.)

Quote
Davide Baccaglini wrote:
So I can't resolve problem in Mapper sample?


This is not a problem. Mapper is a sample that illustrates how to implement certain functionality. It's not intended to show everything that is possible or needed in CBFS.

Of course, Mapper can be extended with tracking of external changes made to the directory being mapped, but this would complicate the sample significantly.

Quote
Davide Baccaglini wrote:
If I add a button in Mapper sample, that call NotifyDirectoryChange, can I solve the problem?


Yes, if you add a button and click it after externally modifying the file, you would solve the issue you have in your scenario.


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 1497 times

Number of guests: 2, 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!