Added dir_exists_and_writable() function