code: function createBookmarkStateDirectory_p(bookmarkStateDir, username) {
    if (bookmarkStateDir === null || bookmarkStateDir === "") {
      return Q();
    }
  
    // Capitalize first character
    function capFirst(str) {
      return str.charAt(0).toUpperCase() + str.slice(1);
    }
  
    function createDir_p(dir, mode, username, label) {
      if (label) {
        label = label + ' ';
      } else {
        label = '';
      }
  
      return Q.nfcall(fs.mkdir, dir, mode)
      .then(function() {
        logger.info(
          capFirst('created ' + label + 'bookmark state directory: ' + dir)
        );
      })
      .then(function() {
        // chown if username was supplied
        if (typeof(username) === 'string') {
          var pw = posix.getpwnam(username);
          return Q.nfcall(fs.chown, dir, pw.uid, pw.gid);
        }
      })
      .fail(function(err) {
        return Q.nfcall(fs.stat, dir)
        .then(function(stat) {
          if (!stat.isDirectory()) {
            logger.error(
              capFirst(label + 'bookmark state directory existed, was a file: ' + dir)
            );
            throw err;
          }
        })
        .fail(function(err2) {
          logger.error(
            capFirst(label + 'bookmark state directory creation failed: ' + dir)
          );
          throw err2;
        });
      });
    }
  
    var userBookmarkStateDir = path.join(bookmarkStateDir, username);
  
    return createDir_p(bookmarkStateDir, '711')
    .then(function() {
      return createDir_p(userBookmarkStateDir, '700', username, 'user');
    })
    .fail(function(err) {
      throw err;
    });
  }
docs: Creates the top-level (system) bookmark state directory, then the user's
  bookmark state directory, and then the app's bookmark state directory.