EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Understanding directory listings

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
Posted: 03/20/2008 16:08:34
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Hello, again. I am working with your Mapper sample and I am having some difficulty understanding it fully. I would appreciate if you could answer some questions for me, even though I am aware that by even asking these questions I am exposing my ignorance to you.

I run your sample and install the driver and then click on the Create Storage button. I then click on the Mount button, filling in "C:\" as the directory to mount. I then add a mount point "T:" by clicking on the Add button and filling in "T:" as the name of the mount point. All this works fine, if I then go to a Windows Explorer window and look at the left hand pane I see my "T:" drive as I would expect. If I then click on the "T:" drive, it fills in the right hand pane with the files and folders from my "C:\" directory, again which is what I would expect.

If I run all this under the Visual C++ debugger and set a break point in your OnEnumerateDirectory callback function, I see that it gets called for every file or directory in the "C:\" directory and you do a Windows FindFile to find the next file in the directory and fill in its name into your EnumerationContext structure.

What I don't understand is how the names of the files and directories get from your EnumerationContext structure to the Windows Explorer window. Who is actually writing those names to the screen?

What I really want to know is how I can replace the list of files obtained by the Windows FileFind routines with my own list of files that I obtain from my database. Also, can I do it in such a way as to minimize the access to my database? In other words, I do not want to do a query for each file name, sort of like what FindFile is doing, but would prefer to do a sort of batch query, whereby I get my filenames in some chunk, say 100 files at a time, or something like that. Do I just create my own EnumerationContext structure and fill it in any way I want to and your code magically puts it out onto the Windows Explorer window for me? Or is there something else I need to do?
Posted: 03/21/2008 00:11:41
by Eugene Mayevski (Team)

Enumeration context is just a placeholder for application-defined data (check documentation for this). You put the file details into out parameters of the callback (FileName, CreationTime etc.)

Please check the code of VMounter or VDisk for examples of a virtual storage where the names don't come from anywhere.

Of course you can get many file names from the DB in one query and store them somewhere. Next you will pass these names one by one via OnEnumerateDirectory. EnumerationContext in this case can be used as a placeholder for a pointer to the object, which contains the file list and the index of the last entry retrieved from that list.

Sincerely yours
Eugene Mayevski
Posted: 03/21/2008 13:46:27
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Do you have a sample that doesn't use wchar strings?
Posted: 03/21/2008 13:58:03
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I changed course and instead of using your mapper sample I tried using your VDisk sample, and instead of putting the files in memory I created them in my database, like it was a virtual disk. That worked fine for a few simple cases, but something I tried doesn't make sense to me. In the VDisk sample, in the AddPoint callback function the sample creates a "\sample" directory and puts a text file into it. Well, I didn't see why that was necessary so I removed the code that did it and everything went screwy. If I then tried to create a New Folder on the virtual disk, I got a Windows message box that said "Cannot create file "New Folder" file not found". Could you explain to me why it is necessary to create that sample directory in order to make everything else work correctly?
Posted: 03/21/2008 14:02:07
by Eugene Mayevski (Team)

Try starting with VMounter sample instead - it's more easy to understand as it doesn't deal with directories.

Sincerely yours
Eugene Mayevski
Posted: 03/21/2008 14:12:27
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Please disregard the message above. I changed some things in my code and now everything is working OK. I'm still working on getting my version of a virtual disk to work completely.
Posted: 03/21/2008 15:24:58
by Vladimir Cherniga (Team)

Code that was placed in the AddMountingPoint creates "\sample" directory and files inside of it are only for demonstration purposes.
Please don't hesitate for asking a questions about any problems with samples code
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.



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