logo       

qlf files and prolog version: msg#01533

Subject: qlf files and prolog version

Whenever I upgrade my SWI-Prolog to a new version, I need to rebuild my .qlf files. No surprises there - the documentation states this quite clearly.

I would like a way to do this automatically, rather than rm-ing them all every time I upgrade (I have a *lot* of data files kicking around that get converted to prolog fact files)

Here is the predicate I use for loading a fact file into a module space (adapted from the wordnet loader). Is there a way to extend this so that the qlf file is regenerated if it can't be loaded? Unfortunately catch/3 doesn't appear to work, I guess because failing to load a .qlf is too serious an error?

load_factfile(PlFile,Mod) :-
        style_check(-discontiguous),
        file_name_extension(Base, _Ext, PlFile),
        file_name_extension(Base, qlf, QlfFile),
        statistics(cputime, CpuOld),
        (   exists_file(QlfFile),
            time_file(QlfFile, QlfTime),
            time_file(PlFile, PlTime),
            QlfTime >= PlTime
        ->  Mod:load_files([QlfFile])
        ;   access_file(QlfFile, write)
        ->  debug(load,'Recompiling ~w',[QlfFile]),
            qcompile(PlFile),Mod:load_files([QlfFile])
        ;   Mod:load_files(PlFile)   % can't write qlf file
        ),
        statistics(cputime, CpuNew),
        Time is CpuNew - CpuOld,
        debug(load,'Loaded ~w into [~w] time:~w',[PlFile,Mod,Time]).

Here is the error:

ERROR: $qlf_load/1: /Users/cjm/obol/data/ont_attribute_and_value.qlf bad version (file version = 41, prolog = 42)

Catching this doesn't work:

?- catch(load_files(['/users/cjm/obol/data/ ont_attribute_and_value.qlf']),E,write(E)). ERROR: $qlf_load/1: /Users/cjm/obol/data/ont_attribute_and_value.qlf bad version (file version = 41, prolog = 42)
ERROR: Failed to load /users/cjm/obol/data/ont_attribute_and_value.qlf


Any ideas?



<Prev in Thread] Current Thread [Next in Thread>