Implement directory? on keg

Fixes #30484.