12.3.16 SP_expand_file_name()

Synopsis

     #include <sicstus/sicstus.h>
     
     spio_t_error_code
     SP_expand_file_name(
        char const *relpath,
        char const *cwd,
        spio_t_bits options,
        char **pabspath);

Expand a file name into an absolute path.

Arguments

relpath
The relative path to expand. It should be an encoded string. The path is subject to syntactic rewriting, as if by absolute_file_name/2.
cwd
If the relpath is a relative path, it is expanded relative to cwd, unless cwd is NULL. If cwd is NULL, a relative relpath is expanded relative to the SICStus working directory (as returned by SP_get_current_dir()).
options
The following option bits can be set:
SP_EXPAND_FILE_NAME_OPTION_DIR
The relpath is expanded as a directory, i.e. *pabspath will be slash terminated.
SP_EXPAND_FILE_NAME_OPTION_NO_CWD
An error is returned if the relpath is not an absolute path after syntactic rewriting.
SP_EXPAND_FILE_NAME_OPTION_NO_ENV
Do not expand system properties and environment variables during syntactic rewriting.
SP_EXPAND_FILE_NAME_OPTION_NO_HOME
Do not expand ‘~’ and ‘~user’ during syntactic rewriting.
SP_EXPAND_FILE_NAME_OPTION_ROOT_SLASH
If the expanded value would refer to the root directory, return a slash terminated absolute path, as if SP_EXPAND_FILE_NAME_OPTION_DIR had been set. By default, an error is returned if the expanded absolute path would refer to a root directory and SP_EXPAND_FILE_NAME_OPTION_DIR is not set.
SP_EXPAND_FILE_NAME_OPTION_ROOT_DOT
If the expanded value would refer to the root directory, return an absolute path terminated with ‘/.’. By default, an error is returned if the expanded absolute path would refer to a root directory and SP_EXPAND_FILE_NAME_OPTION_DIR is not set.

pabspath
On success, *pabspath is set to the expanded path. This value is allocated with SP_malloc() and should be freed with SP_free().

Return Value

On success, *pabspath is set to the expanded path and SPIO_S_NOERR or some other success code is returned.

On failure, an error code is returned.

See Also

cpg-ref-SP_get_current_dir. See ref-fdi-syn, for a description of syntactic rewriting. OS File System.


Send feedback on this subject.