Check the database_dir flag and make sure the directory exists

Hello @majelbstoat, 

Please review the following commits I made in branch 'xiao-check-database-dir'.

4e4f52a92b7c87393185a4d54e3be3332709c6ee (2014-09-04 22:51:22 -0700)
Check the database_dir flag and make sure the directory exists

R=@majelbstoat