2

If I run the prolog scripts like this

user:/home/user$ swipl -f some/path/init.pl  -s another/dir/script.pl

How can I get the relative or full paths: some/path and another/dir or /home/user/some/path and /home/user/another/dir? I need it to locate other files that are let's say in another/dir/xml.

working_directory/2 does'nt do the job. Neither source_file/1 does.

For example, for perl there is FindBin module; also for python there are options.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Fibo Kowalsky
  • 1,198
  • 12
  • 23

1 Answers1

0

You can get the directory of a source file on loading it by using prolog_load_context(directory, D). For example, to switch to the directory of the loaded file, you can use:

:- prolog_load_context(directory, D), working_directory(_, D).
Omar.B
  • 103
  • 3