Ported some directory functions to directories.py