Tricking directory enumeration under wine

Questions about Wine on Linux
Locked
bugsbunny
Newbie
Newbie
Posts: 2
Joined: Tue Mar 15, 2016 3:41 am

Tricking directory enumeration under wine

Post by bugsbunny »

Hello. I have a windows program, that uses native windows directory enumeration to build the list of it's plugins. Each plugin is located in a separate directory. I need my plugin to be the first one loaded, so under windows i name the folder like "!mysuperplugin" and the job is done, the exclamation mark makes it the top folder in both explorer and, apparently, internal listings, but when i launch this program in Linux under wine from EXT-family volumes, the loading order is entirely different, the trick doesn't work anymore and plugins are broken.

Is there some tricky naming conventions i can use for my plugin that will work both under Wine and Windows or at least only under Wine (creating a separate package is not an issue for me)?
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: Tricking directory enumeration under wine

Post by lahmbi5678 »

Did you try something obvious like naming the folders "1myplugin", "2myplugin" and so on? Sorting on 'special' characters like "!" doesn't sound like a good idea anyway.

Does your application explicitly sort the files? Probably not. Maybe your application uses some undocumented behaviour in Windows, e.g. a function that always returns an ordered list of files/folders. Or maybe some function in wine hasn't yet been properly implemented. In either case you should file a bug and maybe provide a simple test case.
bugsbunny
Newbie
Newbie
Posts: 2
Joined: Tue Mar 15, 2016 3:41 am

Re: Tricking directory enumeration under wine

Post by bugsbunny »

From what i understood, it does it's enumeration in alphabetical order, identical to windows command-line's "DIR" output. Folders prefixed with exclamation marks always come on top. On Linux it definitely ignores my exclamation marks and puts it lower in the hierarchy. If there is no other way to cement my position above everything with conventional special characters, i'll try using combined exclamation and numbers then, because there are other plugins on windows starting with "!" and i most definitely will need to be above them. Thanks for your help, i wish i knew the exact technical details about the enumeration to file a bug report. What i have right now is just two different outcomes for rather undocumented very specific, "hacky" interactions and it probably will be rejected.
DarkPlayer
Level 2
Level 2
Posts: 23
Joined: Sun Mar 13, 2016 11:15 am

Re: Tricking directory enumeration under wine

Post by DarkPlayer »

This is a known problem in Wine. When using NTFS as filesystem, the files are returned in alphabetical order while other filesystems like EXT sort files in a different way. More information can be found at https://bugs.winehq.org/show_bug.cgi?id=34122. You might want to subscribe to this bug report to get more information about possible fixes or workarounds.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: Tricking directory enumeration under wine

Post by Bob Wya »

It's a quirk on Windows that NTFS filesystems are sorted alphabetically by the FindFirstFile/FindNextFile methods. Actually Wine does not emulate this "non-standard" behaviour by default...

I'm successfully using this patch from Wine bug 34122 as a Gentoo user patch for my wine install... It works like a charm - but the case insensitivity flag needs to be set to TRUE - as per my comment (25) on the bug...
Locked