check if files are directories when opening directories