===== EXAMPLE #2 (Single Level Directory Scan with entries sorted by Name) static int32 compare_name_hookfunc(struct Hook *hk, struct ExamineData *exd1, struct ExamineData *exd2 ) { struct UtilityIFace *iutil = hk->h_Data; // return iutil->Stricmp(exd1->Name, exd2->Name); return iutil->UTF8Stricmp(exd1->Name, exd2->Name); } int32 sorted_scan( CONST_STRPTR name ) { struct ExamineData *exd; struct List LS; struct Node *n; int32 result = FALSE; APTR context = IDOS->ObtainDirContextTags(EX_StringNameInput,name, EX_DataFields,EXF_ALL, TAG_END); IExec->NewList(&LS); /* initialise empty list */ while((exd = IDOS->ExamineDir(context))) /* until no more data.*/ { IExec->Remove((struct Node *)exd); IExec->AddHead(&LS,(struct Node *)exd); } if( ERROR_NO_MORE_ENTRIES != IDOS->IoErr() ) { IDOS->PrintFault(IDOS->IoErr(),NULL); /* failure */ } else { /* Sort list if utility function available. */ if( LIB_IS_AT_LEAST(UtilityBase, 54, 2) ) { struct Hook HK = { .h_Entry = (HOOKFUNC)compare_name_hookfunc, .h_Data = (APTR)IUtility }; IUtility->SortList(&LS, &HK); } for(n = IExec->GetHead(&LS); n; n = IExec->GetSucc(n) ) { exd = (struct ExamineData *) n; IDOS->Printf("%s\n", exd->Name); } result = TRUE; } IDOS->ReleaseDirContext(context); return(result); } =====