Function to check if something is a directory
Finished, untested, needs more logging of what it's doing