User Awareness of a Prolog System

Dear All,

In Java I find these two system properties
which are usually populated:

user.home: User home directory Operating system name

Is there something similar commonly used
in Prolog systems. In SWI-Prolog I only find:

   ?- current_prolog_flag(home, X).
   X = 'd:/software/logic/swipl'.

   ?- current_prolog_flag(arch, X).
   X = 'x64-win64'.

Which is not exactly the information I am looking
for. I am currently planning to introduce
a new flag:

user_dir: Result of mingling user.home,
relative to

    if (osname != null && osname.startsWith("Windows XP")) {
        file = new File(userhome, "Application Data");
    } else if (osname != null && osname.startsWith("Windows")) {
        file = new File(new File(userhome, "AppData"), "Roaming");
    } else if (osname != null && osname.startsWith("Mac OS X")) {
        file = new File(new File(userhome, "Library"), "Preferences");
    } else {
        file = new File(userhome);

This directory can be used for user settings
and preferences etc… Something similar available
in SWI-Prolog?

Best Regards

This is arranged using file_search_path/2, which notably provides access to personal and shared config and data locations. Not to the user’s home. expand_file_name(~, Home) gets the home directory.

To get ~/Library/Preferences on a mac. Should I use the arch Prolog flag:

?- current_prolog_flag(arch, X).
X = 'x86_64-darwin'

What is the format of the arch flag? Always <cpu>-<os>? The documentation says:

Identifier for the hardware and operating system SWI-Prolog is running on.

What hardware values and operating system values are available?

From cmake/Ports.cmake:


Some port files may define it explicitly (notably platforms for which we cross-compile).

1 Like

Documentation for CMAKE_HOST_SYSTEM_NAME tells me this is
uname -s. But what is it on windows?

Is it fine grained enough to distinguish Windows XP and Windows.
And it could be that the desired information is runtime information,

and not compile time information. Not sure.

The Windows identifiers are fixed for 32 and 64 bits. It doesn’t distinguish different Windows versions. I think there is something that tells you, but I cannot find it this quickly. The whole point of this identifier is to have (mostly) compatible dll/so/dylib files.

This one brings it closer:

?- getenv('APPDATA', X).
X = 'C:\\Users\\foobar\\AppData\\Roaming'.

I guess it might differ between Windows XP and Windows.