function to ensure and load a directory