| 1 | % (c) 2022-2022 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
| 2 | % Heinrich Heine Universitaet Duesseldorf | |
| 3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
| 4 | ||
| 5 | :- module(test_paths, [ | |
| 6 | get_prob_examples_override/1, | |
| 7 | set_prob_examples_override/1, | |
| 8 | unset_prob_examples_override/0 | |
| 9 | ]). | |
| 10 | ||
| 11 | :- use_module(library(system), [environ/2]). | |
| 12 | :- use_module(probsrc(pathes), [runtime_application_path/1]). | |
| 13 | ||
| 14 | :- multifile(user:file_search_path/2). | |
| 15 | :- dynamic(user:file_search_path/2). | |
| 16 | ||
| 17 | set_prob_examples_path(Path) :- | |
| 18 | retractall(user:file_search_path(prob_examples, _)), | |
| 19 | assertz(user:file_search_path(prob_examples, Path)). | |
| 20 | ||
| 21 | get_prob_examples_override(Path) :- prob_examples_override(Path). | |
| 22 | set_prob_examples_override(Path) :- | |
| 23 | retractall(prob_examples_override(_)), | |
| 24 | assertz(prob_examples_override(Path)), | |
| 25 | runtime_application_path(App), | |
| 26 | absolute_file_name(Path, Full, [relative_to(App)]), | |
| 27 | set_prob_examples_path(Full). | |
| 28 | unset_prob_examples_override :- | |
| 29 | retractall(prob_examples_override(_)), | |
| 30 | runtime_application_path(App), | |
| 31 | absolute_file_name('../prob_examples', Full, [relative_to(App)]), | |
| 32 | set_prob_examples_path(Full). | |
| 33 | ||
| 34 | init_prob_examples_override :- | |
| 35 | (environ('PROB_EXAMPLES_DIR', Path) -> | |
| 36 | set_prob_examples_override(Path) | |
| 37 | ; | |
| 38 | % Set default path for prob_examples | |
| 39 | unset_prob_examples_override | |
| 40 | ). | |
| 41 | ||
| 42 | :- initialization(init_prob_examples_override). |