X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fhttp_getter%2Fhttp_getter_map.ml;h=06699f1781a237153c489d950fc89e8ee6a8464c;hb=5d7d6bd5090f3f82279bef0b93b4b361a5b1d751;hp=07c2c10b4a0db1c667bfa4eef2edabb985cd3ce3;hpb=34ce9fa57cd6c138454a69b1a0e6675118e3abc7;p=helm.git diff --git a/helm/http_getter/http_getter_map.ml b/helm/http_getter/http_getter_map.ml index 07c2c10b4..06699f178 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 ( @@ -66,13 +65,27 @@ class map dbname = Dbm.iter f db )) + method sync = + self#doWriter (lazy ( + Dbm.close db; + db <- open_dbm () + )) + 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