createDir function

Create a directory if it does not exist, and then make sure the creation was successful.