EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Multiple folders appearing

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#13041
Posted: 04/20/2010 17:52:26
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

Hi,

I *know* I've had this problem before and resolved it, but I'm still suffering from some v2->v3 hangovers.

I have a virtual drive that is accessed via Explorer with a structure as:

z:\Root
z:\Root\a
z:\Root\b
z:\Root\c
z:\Root\c\mydoc.docx

when I open the word document, the left-side of Windows Explorer (the Folders section) adds copies of the same folders:

z:\Root
z:\Root\a
z:\Root\b
z:\Root\c
z:\Root\c\mydoc.docx
z:\Root\a
z:\Root\b
z:\Root\c

if I click on z:\Root however, the right side (the folder/file list) shows the correct folders, but the left side shows multiple copies.

It only seems to add multiple copies of the folders when I have highlighted the same folder that has the file open, or subsequently save the file. For example, if I select z:\root\c and open the file, I get copies of folders. If I then save, I get more copies. If I select z:\root and then save again, I don't get the copies.

What could be causing that? Should I be looking in the EnumerateDirectory code, or have I messed up a setting somewhere? Anyone seen this behavior before?
#13044
Posted: 04/21/2010 00:45:31
by Volodymyr Zinin (EldoS Corp.)

Hello Gavin,

It seems something is wrong in your OnEnumerateDirectory and OnCloseEnumeration code.
You can track what CallbackFS returns to the system by the use of Process Monitor from sysinternals.com - set the filter there to track your virtual disk (for example "Path" -> "Begins with" -> "X:"). Of course there is no strict correspondence between the callbacks and the system requests but you will be able to see what directory enumeration requests return.
#13047
Posted: 04/21/2010 02:23:43
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

Ah that's a good tip, thanks Vlad. I'll check it out tonight.

([URL=http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx]Process Monitor[/URL] can be found here BTW)
#13056
Posted: 04/21/2010 05:38:29
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

No luck so far with Process Monitor either, it doesn't seem to be picking up the events properly. I've tried several filter combinations but am not getting any enumeration logged events. Maybe that's the problem?

Are you able to explain how Windows Explorer decides whether a folder is different from another folder? Is it only the folder name, or does it also use last written/created/etc? I'm wondering if some other folder value I am returning from EnumDirectory is different, so it is treating it like a new folder.

It seems that all folders *except* the first folder in my filesystem get copied. So of my 5 folders, folders 2-5 get duplicated but folder 1 only has one copy. Weird.
#13057
Posted: 04/21/2010 06:13:39
by Volodymyr Zinin (EldoS Corp.)

Quote
Gavin McKay wrote:
No luck so far with Process Monitor either, it doesn't seem to be picking up the events properly. I've tried several filter combinations but am not getting any enumeration logged events. Maybe that's the problem?

The filter "Path" -> "Begins with" -> "X:" (where "X:" is your drive letter) should work. Try this filter on some already existing disk (for example "C:").

Quote
Gavin McKay wrote:
Are you able to explain how Windows Explorer decides whether a folder is different from another folder? Is it only the folder name, or does it also use last written/created/etc? I'm wondering if some other folder value I am returning from EnumDirectory is different, so it is treating it like a new folder.

It differentiates only by file/folder names. But in your case it seems that the same names are returned several times during the folder enumeration.
#13077
Posted: 04/21/2010 17:29:42
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

That's the part I don't understand - if I am returning the same folder names as part of the enumeration, I would think Explorer would *not* add them again.

Interestingly the first folder never gets duplicated... will raise a ticket for it.
#13080
Posted: 04/22/2010 01:16:23
by Eugene Mayevski (EldoS Corp.)

Of course the system won't filter out duplicate file names for you. It's your job to provide unique file names. Part of the reason is that the OS allows the same file names that differ in case, and for a simple "filename.ext" there can be a myriad of combinations of upper and lower case characters.


Sincerely yours
Eugene Mayevski
#13082
Posted: 04/22/2010 03:52:41
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

Ah I didn't know that - I thought Explorer would auto-filter duplicates, like if I try and create a duplicate named folder in Windows Explorer it will complain. Yet another thing for me to add to my limited knowledge lol

Thanks Eugene.
#13101
Posted: 04/25/2010 19:55:55
by Gavin McKay (Standard support level)
Joined: 09/01/2009
Posts: 48

OK with extensive help from the poor Eldos guys who I have bugged non-stop for 2 weeks lol I've finally sorted this out!

A couple of debugging tips for others who might experience this in the future:
- if you get multiple copies of the same folders/files in Explorer, the issue is in enum directory code, and the way you are returning files/folders from your internal folder structure
- use process monitor to find out what is being called/accessed by explorer. Set the Path to "include" your drive letter (i.e. Z:) to filter out the junk
- check which calls are using a mask and which aren't. For example, a request for Z:\ is asking for the folder, but a call to Z:\* is asking for the enumeration entries.
- NOTE you can't use process monitor if you add a *network* mount point. It only works for a local mount point. Modify your AddMountingPoint address so it uses a local drive (i.e. "Z:") instead of a network drive (i.e. "Z:;;myshare"). When you have it sorted out, switch back to network mount points (I'm using network mount points to reduce the calls to my underlying database filesystem. Local mount points are much more "chatty" and you get a lot more calls)

The VS2008_Mounter application is a basic sample that treats all files and folders as the same item i.e. VirtualFile. My system separates files and folders into VirtualFileObject and VirtualFolderObject. I also maintain separate collections of these in my directory enum code such as Dictionary<string, VirtualFileObject> to make use of strongly-types collections (a hash-table would probably be faster but anyway). The Mounter sample app creates a directory enum context and a stream, regardless of whether the object is a file or a folder, and I wanted to separate the logic for this.

When I return my total file/folder count, I just add _files.Count + _folders.Count to get the total amount. When I iterate through these via enumdirectory, I first iterate the folder collection then the file collection.

My use of the "Mask" (i.e. * for all) was also incorrect, and this caused problems. to.

My previous code did not do this well at all, but it worked in v2 and not in v3. Judging by how bad my original version was, I'm surprised it worked at all lol. I've heavily modified this logic now, and it all works.

Hope this helps someone else.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

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