engine/source/scriptlib/ImportCache.c
/**
 * Returns a pointer to the ImportNode for the specified file.
 *
 * If the file has already been imported, this function returns the pointer to
 * the existing node.  If it hasn't, it imports it and then returns the pointer.
 *
 * Returns NULL if the file hasn't already been imported and an error occurs
 * when compiling it.
 */
Returns a pointer to the ImportNode for the specified file.
If the file has already been imported, this function returns the pointer to
the existing node.  If it hasn't, it imports it and then returns the pointer.

Returns NULL if the file hasn't already been imported and an error occurs
when compiling it.
Returns a pointer to the ImportNode for the specified file . If the file has already been imported this function returns the pointer to the existing node . If it hasn ' t it imports it and then returns the pointer . Returns NULL if the file hasn ' t already been imported and an error occurs when compiling it .
ImportNode *ImportCache_ImportFile(const char *path)
{
    int i;
    char path2[256];
    ImportNode *node;
    assert(strlen(path) <= 255);
    for(i = strlen(path); i >= 0; i--)
    {
        if(path[i] == '\\')
        {
            path2[i] = '/';
        }
        else if(path[i] >= 'A' && path[i] <= 'Z')
        {
            path2[i] = path[i] + ('a' - 'A');
        }
        else
        {
            path2[i] = path[i];
        }
    }
#ifdef IC_DEBUG
    fprintf(stderr, "ImportCache_ImportFile: '%s' -> '%s'\n", path, path2);
#endif
    if(List_FindByName(&imports, path2))
    {
        return (ImportNode *)List_Retrieve(&imports);
    }
    node = malloc(sizeof(ImportNode));
    if(FAILED(ImportNode_Init(node, path2)))
    {
        free(node);
        return NULL;
    }
    List_GotoLast(&imports);
    List_InsertAfter(&imports, node, path2);
    return node;
}
ImportNode * ImportCache_ImportFile ( const char * path ) { int i ; char path2 [ 256 ] ; ImportNode * node ; assert ( strlen ( path ) <= 255 ) ; for ( i = strlen ( path ) ; i >= 0 ; i -- ) { if ( path [ i ] == ' \\ ' ) { path2 [ i ] = ' ' ; } else if ( path [ i ] >= ' ' && path [ i ] <= ' ' ) { path2 [ i ] = path [ i ] + ( ' ' - ' ' ) ; } else { path2 [ i ] = path [ i ] ; } } #ifdef IC_DEBUG fprintf ( stderr , " \n " , path , path2 ) ; #endif if ( List_FindByName ( & imports , path2 ) ) { return ( ImportNode * ) List_Retrieve ( & imports ) ; } node = malloc ( sizeof ( ImportNode ) ) ; if ( FAILED ( ImportNode_Init ( node , path2 ) ) ) { free ( node ) ; return NULL ; } List_GotoLast ( & imports ) ; List_InsertAfter ( & imports , node , path2 ) ; return node ; }
Returns a pointer to the ImportNode for the specified file.
Returns a pointer to the ImportNode for the specified file .
// first convert the path to standard form, lowercase with forward slashes // find and return node if this file has already been imported // otherwise, create a new node for this file, add it to the cache, and return it