X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fcomponents%2Fng_library%2FnCicLibrary.ml;h=3117a12ad387d8458711ab9c50cf9b32271fac4c;hb=520d4370a540a98f5e5e1d85acfef0c982cc1e04;hp=729d62d0ee8696eef3c0b6fbe035d0d8929d53d2;hpb=db7ecce6c398a42f14557067bf18b61cf75da80e;p=helm.git diff --git a/matita/components/ng_library/nCicLibrary.ml b/matita/components/ng_library/nCicLibrary.ml index 729d62d0e..3117a12ad 100644 --- a/matita/components/ng_library/nCicLibrary.ml +++ b/matita/components/ng_library/nCicLibrary.ml @@ -195,6 +195,16 @@ let dump_obj status obj = status#set_dump {status#dump with objs = obj::status#dump.objs } ;; +let remove_objects ~baseuri = + let uri = NUri.string_of_uri baseuri in + let path = String.sub uri 4 (String.length uri - 4) in + let path = Helm_registry.get "matita.basedir" ^ path in + let map name = Sys.remove (Filename.concat path name) in + if HExtlib.is_dir path && HExtlib.is_regular (path ^ ".ng") then begin + HLog.warn ("removing contents of baseuri: " ^ uri); + Array.iter map (Sys.readdir path) + end + module type SerializerType = sig type dumpable_status @@ -250,6 +260,9 @@ module Serializer(D: sig type dumpable_s = private #dumpable_status end) = let ch = open_out (ng_path_of_baseuri baseuri) in Marshal.to_channel ch (magic,(status#dump.dependencies,status#dump.objs)) []; close_out ch; +(* + remove_objects ~baseuri; (* FG: we remove the old objects before putting the new ones*) +*) List.iter (function | `Obj (uri,obj) -> @@ -324,10 +337,10 @@ let aliases_of uri = if NUri.eq uri' uri then Some nref else None) !local_aliases ;; -let add_obj status ((u,_,_,_,_) as obj) = - NCicEnvironment.check_and_add_obj status obj; - storage := (`Obj (u,obj))::!storage; - let _,height,_,_,obj = obj in +let add_obj status ((u,_,_,_,_) as orig_obj) = + NCicEnvironment.check_and_add_obj status orig_obj; + storage := (`Obj (u,orig_obj))::!storage; + let _,height,_,_,obj = orig_obj in let references = match obj with NCic.Constant (_,name,None,_,_) -> @@ -384,4 +397,4 @@ let get_obj status u = raise (NCicEnvironment.ObjectNotFound (lazy (NUri.string_of_uri u))) ;; -NCicEnvironment.set_get_obj get_obj;; +NCicEnvironment.set_get_obj get_obj