Bug on listfolder()

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Bug on listfolder()

Post 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.

admin
Site Admin
Posts: 67340
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Bug on listfolder()

Post 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...)

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Bug on listfolder()

Post 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:

JohnM
Posts: 305
Joined: 08 Jun 2006 11:59
Location: Windows 11 Pro @100%

Re: Bug on listfolder()

Post 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
Windows 11 Pro x64
XYplorer 28.40.0612 x64

admin
Site Admin
Posts: 67340
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Bug on listfolder()

Post 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

Post Reply