Added a check for whether the data directory is writable

Added a check for whether the data directory is writable, and provide a more exact error text in this case.