+static notmuch_status_t
+_db_dir_exists (const char *database_path, char **message)
+{
+ struct stat st;
+ int err;
+
+ err = stat (database_path, &st);
+ if (err) {
+ IGNORE_RESULT (asprintf (message, "Error: Cannot open database at %s: %s.\n",
+ database_path, strerror (errno)));
+ return NOTMUCH_STATUS_FILE_ERROR;
+ }
+
+ if (! S_ISDIR (st.st_mode)) {
+ IGNORE_RESULT (asprintf (message, "Error: Cannot open database at %s: "
+ "Not a directory.\n",
+ database_path));
+ return NOTMUCH_STATUS_FILE_ERROR;
+ }
+
+ return NOTMUCH_STATUS_SUCCESS;
+}
+