Hi just noticed that using ParsePatternNoCase() and ObtainDirContextTags() I get something like this:
[gui_resources.c:487 ] searching "STRIDER.gs[0-9]":
[gui_resources.c:511 ] 'STRIDER.gs1'
[gui_resources.c:514 ] slot #1
[gui_resources.c:511 ] 'STRIDER.gs5'
[gui_resources.c:514 ] slot #5
[gui_resources.c:511 ] 'STRIDER.gs3'
[gui_resources.c:514 ] slot #3
[gui_resources.c:511 ] 'STRIDER.gs0'
[gui_resources.c:514 ] slot #0
Just wandering why .gs0 is the last one, shouldn't it be the first match?
Snipped of my code:
... IUtility->Strlcpy(filestate, fn, MAX_DOS_FILENAME); IUtility->Strlcat(filestate, ".gs[0-9]", MAX_DOS_FILENAME); DBUG(" searching \"%s\":\n",filestate); // Detach chooser list [...] // Search selected/active rom savestates IDOS->ParsePatternNoCase(filestate, pattern_ms, 2+MAX_DOS_FILENAME*2); context = IDOS->ObtainDirContextTags(EX_StringNameInput, SAVES, EX_DataFields, (EXF_NAME|EXF_TYPE), EX_MatchString, pattern_ms, TAG_END); if(context) { struct ExamineData *dat; while( (dat=IDOS->ExamineDir(context)) ) { if( EXD_IS_FILE(dat) ) { char slot[2] = ""; DBUG(" '%s'\n",dat->Name); ...
TiA
EDIT1: seems it takes into account the date of files ¿:-/ so if .gs0 is newer it shows last.
EDIT2: tried to get "initial" behaviour,but now always is sorted correctly ¿:-/
Directory entries are returned in no specific order. The order might even change between program executions. It depends on file system implementation and internal structures and maybe caching.
If you want the entries to be ordered, for example names ascending alphabetically, you have to sort them yourself.
ok, so if they are sorted it's by pure luck (maybe). thanks
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Example #2 in the latest dos.doc for ExamineDir() has sorting example code.
File attachments:
@cwenzel
This example makes mention of function 'SortList' in utility.library, but when looking at the the only documentation on that library, there is no such function to be found. The list jumps from 'SNPrintf' straight to 'Stricmp' and in alphabetical order 'SortList' should be right in between these two. Just an observation.
OldFart
@OldFart
Do you have an older version of the SDK, perhaps? I see both SortList() and SortMinList(). They were added in utility.library v. 54.2, which I believe is OS 4.1 FE.
Those functions are missing from the OS4 documentation wiki, which apparently hasn't been updated.
@msteed
I was looking at the online documentation on the library. A typo with a pretty high level of severity:
, which was meant to read: "...but when looking at the online documentation on the library..." should have clarified my source.
But does this indicate that online documentation is no longer maintained?
OldFart
THX didn't know such example.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Hi, "reopening" this thread, just a doubt:
Why do you "pass" .h_Data = (APTR)IUtility? I have it already open as global.
BTW works great (with my changes to use in a chooser_gd list).
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Out of habit I guess, I usually write re-entrant library type code and rarely use global variables.
I grabbed that example code from an actual piece of working code I tested and just used a
local 'iutil' passd in the hook as h_Data. Just ignore it in the hook() and use IUtility->
I have modified the example in the autodoc to use a global interface everywhere now.
Thanks for being observant.