4.36 File System Interaction
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • File System Interaction
          • access_file/2
          • exists_file/1
          • file_directory_name/2
          • file_base_name/2
          • same_file/2
          • exists_directory/1
          • delete_file/1
          • rename_file/2
          • size_file/2
          • time_file/2
          • absolute_file_name/2
          • absolute_file_name/3
          • is_absolute_file_name/1
          • file_name_extension/3
          • directory_files/2
          • expand_file_name/2
          • prolog_to_os_filename/2
          • read_link/3
          • tmp_file/2
          • tmp_file_stream/3
          • make_directory/1
          • delete_directory/1
          • working_directory/2
          • chdir/1
    • Packages
Availability:built-in
expand_file_name(+WildCard, -List)
Unify List with a sorted list of files or directories matching WildCard. The normal Unix wildcard constructs `?', `*', `[ ... ]' and `{...}' are recognised. The interpretation of `{...}' is slightly different from the C shell (csh(1)). The comma-separated argument can be arbitrary patterns, including `{...}' patterns. The empty pattern is legal as well: `{.pl,}' matches either `.pl' or the empty string.

If the pattern contains wildcard characters, only existing files and directories are returned. Expanding a `pattern' without wildcard characters returns the argument, regardless of whether or not it exists.

Before expanding wildcards, the construct $\arg{var} is expanded to the value of the environment variable var, and a possible leading ~ character is expanded to the user's home directory.142On Windows, the home directory is determined as follows: if the environment variable HOME exists, this is used. If the variables HOMEDRIVE and HOMEPATH exist (Windows-NT), these are used. At initialisation, the system will set the environment variable HOME to point to the SWI-Prolog home directory if neither HOME nor HOMEPATH and HOMEDRIVE are defined.