EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Knowing which file to open

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#27743
Posted: 12/23/2013 07:21:44
by pnina (Standard support level)
Joined: 11/20/2013
Posts: 36

I am using the VDisk sample as a basis to create files and folders structure from some list I have, using the VirtualFile class. So basically my files on the virtual drives are empty with all the properties: name, size, etc.

Let's say my drive is mounted to a mounting point "X:", then I have a folder named "a" and inside it I have folders "b", "c", and files "1.pdf", "2.txt".

If a user is trying to open a file from my virtual drive (for example- X:\a\1.pdf), I want to actually create this file (provide a stream and write it there), and then to open it.

I wanted to do it inside the CbFsOpenFile event, and get the correct stream based on the FileName.
When I double-clicked "1.pdf", CbFsOpenFile is fired, and the FileName is set to "a\1.pdf".
But even when I enumerate directory "a", it calls CbFsOpenFile for all a's content, which is: b,c,1.pdf,2.txt.

So basically I can't know what called CbFsOpenFile event. It can be the file itself or the parent folder.

How can I know which file the user is trying to open?
Is there a property to indicate what the user have clicked?
#27744
Posted: 12/23/2013 07:24:18
by Eugene Mayevski (EldoS Corp.)

Quote
testt4558 wrote:
When I double-clicked "1.pdf", CbFsOpenFile is fired, and the FileName is set to "a\1.pdf". But even when I enumerate directory "a", it calls CbFsOpenFile for all a's content, which is: b,c,1.pdf,2.txt.


And those files ARE opened by Explorer.


Sincerely yours
Eugene Mayevski
#27745
Posted: 12/23/2013 07:27:15
by pnina (Standard support level)
Joined: 11/20/2013
Posts: 36

Yes, I understand.
But how can I know on which file the USER double clicked to open?
Not the explorer..
#27746
Posted: 12/23/2013 07:39:06
by Eugene Mayevski (EldoS Corp.)

The filesystem knows nothing about users. It knows only about OS requests. So you must open the file that you've been asked to open.


Sincerely yours
Eugene Mayevski
#27747
Posted: 12/23/2013 08:00:51
by pnina (Standard support level)
Joined: 11/20/2013
Posts: 36

So in this case is it better to do it in the CbFsReadFile event?
From what I saw it only opens the requested file and nothing else. Is it correct?
#27748
Posted: 12/23/2013 08:03:18
by Eugene Mayevski (EldoS Corp.)

If the file is opened, in most cases it will be read from. Explorer opens files to get their metadata when the directory is browsed.

Of course you can start reading from the file only when OnReadFile event comes, that's up to you.


Sincerely yours
Eugene Mayevski
#27759
Posted: 12/23/2013 20:13:26
by Andrew Pratt (Standard support level)
Joined: 03/01/2013
Posts: 4

Sorry this is a very quick response but hopefully points you in the right direction.

The two things you need to look into are stopping Explorer creating thumbnails/previews for your files and determining the process that is opening the file - there is an example of how to determine that it is explorer.exe requesting the open file.
#27760
Posted: 12/24/2013 03:54:40
by pnina (Standard support level)
Joined: 11/20/2013
Posts: 36

Andrew I would appreciate if you can explain more specifically or with an example :)
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 1567 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!