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
os.name: Operating system name
System Properties (The Java™ Tutorials > Essential Java Classes > The Platform Environment)

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 os.name.

    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.

From cmake/Ports.cmake:

if(NOT SWIPL_ARCH)
  string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM_NAME}
         SWIPL_ARCH)
endif()

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.