dir.c: use the cache_* macro to access the current index