Factored out dirinfo stuff

In preparation of a testing endeavour i factor out everything concerning
the `dirinfo` structure and management of that.