Expand ~ in path.
Make sure the directory for csearchindex file exist.