Old 19th April 2017, 13:09   #1
systracer
Junior Member
 
Join Date: Apr 2014
Posts: 7
Strange work of FindFirst function

Good day! I find some strange work of FindFirst/FindNext and Locate function.
For example we have 10 dirs on local hard drive:
Quote:
2017-03-23_02.00.00
2017-03-24_02.00.00
2017-04-05_02.00.03
2017-04-08_02.00.03
2017-04-11_02.00.02
2017-04-12_02.00.03
2017-04-14_02.00.03
2017-04-17_02.00.03
2017-04-18_02.00.02
2017-04-19_02.00.03
And we Find them. All works normal: we get exactly this list in ascending order.
But if this folders locate on network share, connected as letter, we get random order, but each time the same:
Quote:
2017-04-19_02.00.03
2017-04-05_02.00.03
2017-04-08_02.00.03
2017-04-14_02.00.03
2017-03-23_02.00.00
2017-03-24_02.00.00
2017-04-12_02.00.03
2017-04-18_02.00.02
2017-04-17_02.00.03
2017-04-11_02.00.02
Can this behavior be corrected?
systracer is offline   Reply With Quote
Old 19th April 2017, 14:33   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,533
Windows does not sort the results. Some filesystems store the directory entries sorted, some store them by creation time. NSIS just returns the entries without any extra sorting.

Quote:
The order in which the search returns the files, such as alphabetical order, is not guaranteed, and is dependent on the file system. If the data must be sorted, the application must do the ordering after obtaining all the results.
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

If you are displaying the files in a listbox you can set a style to get the listbox to sort for you...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th April 2017, 16:24   #3
systracer
Junior Member
 
Join Date: Apr 2014
Posts: 7
Anders, thanks for answer! I think is universally to sort list in array, if it can't be done more easy.
systracer is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump