From: Stefano Zacchiroli Date: Thu, 26 Dec 2002 19:57:46 +0000 (+0000) Subject: - clear also .db db files X-Git-Tag: v0_3_99~111 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=12e7928b2ce2113d5ac43d453026d0443f58c5e4;p=helm.git - clear also .db db files - added #close method --- diff --git a/helm/http_getter/http_getter_map.ml b/helm/http_getter/http_getter_map.ml index 7a5ed1a3b..26daa21d5 100644 --- a/helm/http_getter/http_getter_map.ml +++ b/helm/http_getter/http_getter_map.ml @@ -40,7 +40,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 ( @@ -75,10 +75,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 diff --git a/helm/http_getter/http_getter_map.mli b/helm/http_getter/http_getter_map.mli index 3e0cd0878..b0725b8de 100644 --- a/helm/http_getter/http_getter_map.mli +++ b/helm/http_getter/http_getter_map.mli @@ -36,4 +36,6 @@ class map: method iter: (string -> string -> unit) -> unit method sync: unit method clear: unit + + method close: unit (* use with caution! *) end