Directory Listing

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Directory Listing

Post by *nula »

As this is first time i write into this forum - i want to thank you author for this brilliant piece of software. I cannot even imagine using windows without Total Commander.. :)

Now to the bug - or at least what i believe to be bug:
First i must apologize, i don't have any video, nor do i have any screenshot - if you want it i can make some, but i don't think it would help.

There is probably a problem with Directory Listing. Lets say we have a directory called "SOMETHING" and it has 1000 subdirectories. When i change directory to "SOMETHING" Total Commander will probably send to system some FindFiles(\"SOMETHING"\*) request. But the problem is, that it doesn't send only one such request, but it sends it 1000(the same number, as there are subdirectories) times. - it doesn't asks for \"SOMETHING"\subdir1\*, \"SOMETHING"\subdir2\*, etc.. but every time for the same \"SOMETHING"\*.
Maybe it doesn't look like a problem, and truth is, that on normal systems this isn't a big issue... but im trying to write my own filesystem - and my filesystem is asking database for every subdir - normally it shouldnt be problem, but when i do have lets say 1000 or more subdirs - it will ask 1000x1000 times ..and its starting to be very very slow.
When i try the same situation on simple windows explorer. or i process just simple DIR command in console - my filesystem is asked only once for FindFiles(\"SOMETHING"\*).
Now, im not sure its Total Commander Bug - maybe its somewhere on my filesystem side. Maybe im not returning some data, that i should.. im really not sure, since i don't see into Total Commander code, but i really would like to solve this problem.

If you need any more info, i would gladly provide it to you. Also if you need any special reproduction data, or whatever...
Thank you

P.S.: Its probably no-use info, but im using dokan "platform" to build own filesystem.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50531
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

There is no FindFiles function. There are 3 Functions:
FindFirstFile
FindNextFile
FindClose

Total Commander just calls FindFirstFile, then a loop with FindNextFile until it reports an error or "no more files", and then FindClose.
Author of Total Commander
https://www.ghisler.com
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

Ah, then the usual way.. truth is it didnt came to my mind to try it in my own application. - maybe i'm just unnecessarily return all the data at once.

I assume, you just call it with parameter PATH\* ?

I'll try to investigate more.. thanks for info
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

TC just asks for single folder contents when you enter it, it doesn't ask for entire tree contents.
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

2MVV: right it doesnt, but it does do what i wrote just above.

I just wrote a simple test:

Code: Select all

#include "stdafx.h"
#include <Windows.h>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	HANDLE			hFind;
	WIN32_FIND_DATAW	findData;

	hFind = FindFirstFile(argv[1], &findData);

	if (hFind == INVALID_HANDLE_VALUE) {
		return -1;
	}

	do {
		wcout << findData.cFileName << endl;
	} while (FindNextFile(hFind, &findData) != 0);
	
	FindClose(hFind);
	return 0;
}
And tried it - get one request from kernel to my driver for listing the directory passed as parameter (asctually i pass for example v:\* , where v:\ is my virtual drive and contains 3 subdirectories) - it write down 4 lines - 3 subdirectories and ..

when i change the directory in Total Commander - my kernel receives 4 request from kernel for listing.
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

I tried one more test. I have tried an old file manager FAR(although i dont use it any more, in fact, i dont use any other filemanager, only TotalCMD). Its the same story, FAR also sends just one request to the system(or actually kernel sends just one request for to the driver). Im not sure whats causing these many requests. Maybe its some kernel thing, although i doubt it. Anyway please can you look once more into the code, if there isnt some strange forgotten cycling or something? Im already getting desperate of this and i cannot find any error on my driver side :(

Thank you.


..also .. isnt it possible, that you list all the files, and then again you try to access every single item in the directory, for some additional data?
Sob
Power Member
Power Member
Posts: 945
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

I tried with Process Monitor and usually there is only one QueryDirectory C:\somedirectory\*. But if an exe file is present in that directory and extracting of icons is enabled, then additional QueryDirectory C:\somedirectory\* are present, one for each existing exe.
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

AAAAAAAA thank you so much Sob, i would kiss your feet :-))))

its not only for .EXE, but also for directories. But when i switch icons OFF, its working as i supposed...

Thank you very much, once more...

Anyway .. maybe it would be nice, not to do QueryDirectory c:\somedirectory\* but only QueryDirectory c:\somedirectory\thedirectoryimnowaskingfor ? - when you are looking for icons... :)
Sob
Power Member
Power Member
Posts: 945
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

It does it only for exe files here, not for directories. I even tried to assign icons for them using desktop.ini and still nothing. There must be something else it depends on.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50531
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You may also get additional queries for custom colors, user-defined associations and tooltips, depending on what filters you use.
Author of Total Commander
https://www.ghisler.com
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

Actually on older versions(i have tried 7.04a) of TCMD, i get this QueryDir even if i do have icons switched to none...
On the 7.55a which have i tried right now.. it works as i said - i got QueryDir(actualdir/*) for every subdir in actual directory, when dont set without icons.

Actually ghisler, id like to ask you - would it be possible to optimize somehow this queries? For example these queries for icons.. Is it even necessary to do this queries again? Or would it be possible to use there FindFirst(actualdir/ActualItemYouAreChecking) instead of FindFirst(actualdir/*) ?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50531
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

???
I don't re-read the entire directory for each icon.
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 945
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

Right, it must be something else, it does not occur on clean Windows (tested on XP and W7). Process Explorer shows only one QueryDirectory for c:\somedir\*.
But in case more of the same requests are shown, they're all made by TC process according to PE. Could it be caused by some shell extension or something like that?
nula
Junior Member
Junior Member
Posts: 7
Joined: 2010-07-26, 07:24 UTC
Location: Czech Republic

Post by *nula »

2ghisler: Im sorry, you are right, there is some issue within my driver. Your are processing QUERYDIR for every actual directory, but only for this particular directory. - isnt it so?
Lets say we have:
DIRECTORY
|____SUBDIR1
|____SUBDIR2

at first you do QUERYDIR(DIRECTORY/*) and then
QUERYDIR(DIRECTORY/SUBDIR1) ; QUERYDIR(DIRECTORY/SUBDIR2)
isnt it so? And my stupid driver translated QUERYDIR(DIRECTORY/SUBDIR1) to QUERYDIR(DIRECTORY/*)

QUERYDIR corresponds to findfirst(), findnext() pair. (findfirst and findnext is probably handled by system itself, my driver receives only one QUERYDIRECTORY for this pair)


2Sob: Thank you very much for bringing my attention to the process monitor for spying the process actions :) i didnt know such tool even exists. I knew process explorer, but didnt know this functionality of spying process actions. I have one more questions: i know you've said you use process explorer - but i cannot find any function for spying process actions, i had to use process monitor - you really used process explorer? And if so, how did you showed up the process actions?

Thanks guys.. and sorry for bothering you :(
Sob
Power Member
Power Member
Posts: 945
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

nula wrote:... you really used process explorer?
Nope, my fault, I meant Process Monitor.
Post Reply