35
36:- module(swish_paths, []). 37:- use_module(library(http/http_path), []).
42:- initialization initialize_paths. 43
44:- multifile
45 user:file_search_path/2,
46 http:location/3. 47
48user:file_search_path(data, data).
49user:file_search_path(config_enabled, 'config-enabled').
50user:file_search_path(config_enabled, swish('config-enabled')).
51user:file_search_path(config, config_enabled(.)).
52user:file_search_path(config, swish('config-available')).
53user:file_search_path(swish_web, swish(web)).
54user:file_search_path(swish_pack, swish(pack)).
55user:file_search_path(js, config('web/js')).
56user:file_search_path(js, swish_web(js)).
57user:file_search_path(css, swish_web(css)).
58user:file_search_path(icons, config('web/icons')).
59user:file_search_path(icons, swish_web(icons)).
60user:file_search_path(plugin, config('web/plugin')).
66set_swish_path :-
67 absolute_file_name(swish('swish.pl'), _,
68 [file_errors(fail), access(read)]), !.
69set_swish_path :-
70 prolog_load_context(directory, Dir),
71 !,
72 asserta(user:file_search_path(swish, Dir)).
73set_swish_path :-
74 current_prolog_flag(saved_program, true).
80attach_local_packs :-
81 attach_packs(swish_pack(.), [duplicate(replace), search(first)]).
87set_data_path :-
88 absolute_file_name(data(.), _,
89 [ file_type(directory),
90 access(write),
91 file_errors(fail)
92 ]), !.
93set_data_path :-
94 absolute_file_name(data(.), Dir,
95 [ solutions(all)
96 ]),
97 \+ exists_directory(Dir),
98 catch(make_directory(Dir),
99 error(permission_error(create,directory,Dir), _),
100 fail), !,
101 print_message(informational, swish(created_data_dir(Dir))).
102set_data_path :-
103 print_message(error, swish(no_data_dir)),
104 halt(1).
105
106initialize_paths :-
107 set_swish_path,
108 attach_local_packs,
109 set_data_path.
110
112
113http:location(swish, root(.), [priority(-100)])
Setup SWISH search paths
*/