Page 1 of 1

Bug on listfolder()

Posted: 25 Jan 2012 21:57
by PeterH
Me again... 8)

In some strange situation I seem to have a bug with listfolder().

The issued command, as taken from the STEP-view:
$listfold = listfolder("e:\daten\xyplorer\scripts", "*.xys", 5);
(I tested this, followed by " msg $listfold;" in Try Script, and it showed the same problem.)

The directory contains, besides "§§§.xys" files, some other filetypes, and (very special!) some saved versions of scripts named "§§§.xys S01" etc.

The listfolder(..., "*.xys", 5) returns all "*.xys" and also "*.xys s??"! (All other filetypes are correctly filtered.) So the result is as if the filter were "*.xys*".
(I also tested files §§§.xysS01 and §§§.xysbak - they are wrongly returned, too. But §§§.xys.bak is correctly filtered!)

Help says for pattern: If no wildcards are contained, the pattern is auto-embraced by "*" (unless flag NoAutoWildcards is set).
As "*.xys" does contain a wildcard I assumed that exactly this pattern must be matched. (I.e. "*.xys", not "*.xys*".) But finding the NoAutoWildcards-flag I also tested with flags=13 (=5+8), but it made no difference.

So it looks as if for pattern "*.xys" an asterisk is illegally added at the end.

Re: Bug on listfolder()

Posted: 26 Jan 2012 12:08
by admin
WOW. You never stop learning.

It's not XY that makes a mistake, but apparently the FindFirstFile API does not handle this type of pattern correctly. After numerous tests it looks like only the first 3 letters of the extension are checked, the rest is simply ignored. WOW. Incredible API bug. And it's even present in Win7! :shock:

Well, I know what I have to do now. (Damn I had other plans for today...)

Re: Bug on listfolder()

Posted: 26 Jan 2012 16:44
by PeterH
admin wrote:WOW. You never stop learning.

It's not XY that makes a mistake, but apparently the FindFirstFile API does not handle this type of pattern correctly. After numerous tests it looks like only the first 3 letters of the extension are checked, the rest is simply ignored. WOW. Incredible API bug. And it's even present in Win7! :shock:

Well, I know what I have to do now. (Damn I had other plans for today...)
In between the time it's past tense: you have done it! 8)

And now it works as it should. :D

OK: I will go and have a look for the next problem :wink:
...and if I don't find a problem I will look for a wish :roll:

Re: Bug on listfolder()

Posted: 26 Jan 2012 20:19
by JohnM
Hi all,

Might the registry key "Win95TruncatedExtensions" (http://support.microsoft.com/kb/164351) have something to do with this?

The link is old but it might be still relevant. Just a thought?

Cheers John

Re: Bug on listfolder()

Posted: 27 Jan 2012 09:35
by admin
JohnM wrote:Hi all,

Might the registry key "Win95TruncatedExtensions" (http://support.microsoft.com/kb/164351) have something to do with this?

The link is old but it might be still relevant. Just a thought?

Cheers John
Maybe, but on that page they clearly say "from the command prompt" and do not mention any API. The issue is not mentioned in their description of FindFirstFile (http://msdn.microsoft.com/en-us/library ... 85%29.aspx).

A quick search brought up other people that have been bitten by this:
http://www.codeguru.com/forum/showthread.php?p=278833