Table Of Contents

Previous topic

Type Definitions

Next topic

Threads

Path Functions

Platform independent filesystem path routines.

Summary

s_file_exists Query if a file exists.
s_path_combine Combine a base path and a file name.
s_get_base_path Get the base path of the given absolute file name.

Functions

s_bool s_file_exists(const char *path, const char *mode, s_erc *error)

Query if a file exists.

Also if the file can be manipulated in a certain mode (i.e. reading, writing, ...)

Parameters:
  • path

    The path and name of the file to query.

  • mode

    The mode string as used by the standard function fopen().

  • error

    Error code.

Return:

TRUE if the file exists and can be manipulated with mode, or FALSE.

char *s_path_combine(const char *base_path, const char *filename, s_erc *error)

Combine a base path and a file name.

If the file name is absolute then just a copy of it is returned. Otherwise, build a path to it by considering it is relative to base_path. URL are supported.

Parameters:
  • base_path

    The base path relative to the given file name.

  • filename

    The file name, can be relative or absolute.

  • error

    Error code.

Return:

The combined base and file name.

Note:

Caller is responsible for memory of returned string.

char *s_get_base_path(const char *absolute_filename, s_erc *error)

Get the base path of the given absolute file name.

Parameters:
  • absolute_filename

    The absolute file name.

  • error

    Error code.

Return:

The base path of the given absolute file name.

Note:

Caller is responsible for memory of returned string.