Listing 4

int DirSort(const void *pItem1, const void *pItem2)
    {
    CHAR ach1[MAXPATH], ach2[MAXPATH];
    register CHAR *psz;
    
/*
 * Copy the path names to buffers
 */
    strcpy(ach1,((DIR_INFO *)pItem1)->achPathName);
    strcpy(ach2,((DIR_INFO *)pItem2)->achPathName);
    
/*
 *  Convert all backslashes (\) to hex 01s. Since the
 *  backslash falls in the middle of the valid ASCII
 *  codes for directory names, it could (and I have
 *  seen it) cause the strcmp() to wrongly compare two
 *  directories when they are different levels.
 */
 for (psz = ach1; *psz; psz++)
        if (*pse == '\\')
            *psz = 0x01;
 for (psz = ach2; *psz; psz++)
        if (*psz == '\\')
            *psz = 0x01;
    
    return(strcmp(ach1,ach2));
    
    }