示例#1
0
文件: mcache.c 项目: ArmstrongJ/wmake
STATIC DHEADPTR findDir( const char *path )
/******************************************
 * Walk the directory linked list, and find the directory with the name
 * path.  (Path must end in \ - ie: as returned by _splitpath() )
 * Returns NULL if not found, or if cacheHead == NULL.
 * Move the directory to the beginning of the list (adaptive search)
 */
{
    DHEADPTR    dcur;
    DHEADPTR    dlast;
    char        first;

    dlast = NULL;
    dcur = cacheHead;
    first = path[0];
    while( dcur != NULL && (first != dcur->dh_name[0] ||
                            myCmp( dcur->dh_name, path ) != 0) ) {
        dlast = dcur;
        dcur = dcur->dh_next;
    }

    if( dlast != NULL && dcur != NULL ) {   /* promote directory to head */
        dlast->dh_next = dcur->dh_next;
        dcur->dh_next = cacheHead;
        cacheHead = dcur;
    }

    return( dcur );
}
示例#2
0
STATIC CENTRYPTR findFile( DHEADPTR dir, const char *name )
/**********************************************************
 * Given a directory, find a file within that directory.
 * Return NULL if file not found.
 */
{
    CENTRYPTR   ccur;
    HASH_T      h;

    h = Hash( name, HASH_PRIME );

    for( ccur = dir->dh_table[h]; ccur != NULL; ccur = ccur->ce_next ) {
        if( myCmp( ccur->ce_name, name ) == 0 ) {
            return( ccur );
        }
    }

    return( NULL );
}