X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fupdate_file.c;h=7b211c0fb36da33f0d4fa5486d752824f5f5bc11;hb=2c381d0b592241769db6e2b599e60c1712604a57;hp=59e331cbc092e2fa72da9168d0464657190c6d35;hpb=fc83d98d346711f446d9f9a29cc2ff0eee398053;p=idzebra-moved-to-github.git diff --git a/index/update_file.c b/index/update_file.c index 59e331c..7b211c0 100644 --- a/index/update_file.c +++ b/index/update_file.c @@ -1,4 +1,4 @@ -/* $Id: update_file.c,v 1.1 2006-05-30 13:21:16 adam Exp $ +/* $Id: update_file.c,v 1.3 2006-09-11 22:57:54 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -297,15 +297,47 @@ static void file_update_top(ZebraHandle zh, Dict dict, const char *path) } } -ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) +static ZEBRA_RES zebra_open_fmatch(ZebraHandle zh, Dict *dictp) { - Dict dict; - if (!(dict = dict_open_res (zh->reg->bfs, FMATCH_DICT, 50, + char fmatch_fname[1024]; + int ord; + + ord = zebraExplain_get_database_ord(zh->reg->zei); + sprintf(fmatch_fname, FMATCH_DICT, ord); + if (!(*dictp = dict_open_res (zh->reg->bfs, fmatch_fname, 50, zh->m_flag_rw, 0, zh->res))) { - yaz_log (YLOG_FATAL, "dict_open fail of %s", FMATCH_DICT); + yaz_log (YLOG_FATAL, "dict_open fail of %s", fmatch_fname); + return ZEBRA_FAIL; + } + return ZEBRA_OK; +} + +ZEBRA_RES zebra_remove_file_match(ZebraHandle zh) +{ + Dict dict; + + if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK) return ZEBRA_FAIL; + + dict_clean(dict); + dict_close(dict); + + return ZEBRA_OK; +} + +ZEBRA_RES zebra_update_file_match(ZebraHandle zh, const char *path) +{ + Dict dict; + + if (zebraExplain_curDatabase (zh->reg->zei, zh->basenames[0])) + { + if (zebraExplain_newDatabase(zh->reg->zei, zh->basenames[0], 0)) + return ZEBRA_FAIL; } + if (zebra_open_fmatch(zh, &dict) != ZEBRA_OK) + return ZEBRA_FAIL; + if (!strcmp(path, "") || !strcmp(path, "-")) { char src[1024];