X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fhttp_getter%2Fhttp_getter_map.ml;h=b7ac1c605d7a4d435f9642205dd1a315e07fc2c6;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=7a5ed1a3bc93ca1490b607f7574bd65e78acffde;hpb=e7ab167b72dc48d260d82060949e8ebe7d27764c;p=helm.git diff --git a/helm/http_getter/http_getter_map.ml b/helm/http_getter/http_getter_map.ml index 7a5ed1a3b..b7ac1c605 100644 --- a/helm/http_getter/http_getter_map.ml +++ b/helm/http_getter/http_getter_map.ml @@ -1,5 +1,7 @@ (* - * Copyright (C) 2000, HELM Team. + * Copyright (C) 2003: + * Stefano Zacchiroli + * for the HELM Team http://helm.cs.unibo.it/ * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science @@ -21,12 +23,9 @@ * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, - * http://cs.unibo.it/helm/. + * http://helm.cs.unibo.it/ *) -let debug = true;; -let debug_print s = if debug then prerr_endline s;; - exception Key_already_in of string;; exception Key_not_found of string;; @@ -40,7 +39,7 @@ class map dbname = val mutable db = open_dbm () - initializer Gc.finalise Dbm.close db (* close db on GC *) + (*initializer Gc.finalise Dbm.close db (* close db on GC *)*) method add key value = self#doWriter (lazy ( @@ -49,6 +48,11 @@ class map dbname = with Dbm.Dbm_error "Entry already exists" -> raise (Key_already_in key) )) + method replace key value = + self#doWriter (lazy ( + Dbm.replace db key value + )) + method remove key = self#doWriter (lazy ( try @@ -75,10 +79,18 @@ class map dbname = method clear = self#doWriter (lazy ( Dbm.close db; - Sys.remove (dbname ^ ".dir"); - Sys.remove (dbname ^ ".pag"); + List.iter + (fun ext -> + let file = dbname ^ ext in + if Sys.file_exists file then Sys.remove file) + [".dir"; ".pag"; ".db"]; db <- open_dbm () )) + method close = + self#doWriter (lazy ( + Dbm.close db + )) + end