mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
af5c3afa91
the POSIX 2008 behaviour of realpath is not available everywhere so we provide a simple wrapper function. We use (and provide) the gnu extension canonicalize_file_name to make it cleaner to test for the feature we need; otherwise we have to rely on realpath segfaulting if the second argument is null.
18 lines
377 B
C
18 lines
377 B
C
#include "compat.h"
|
|
#include <limits.h>
|
|
#undef _GNU_SOURCE
|
|
#include <stdlib.h>
|
|
|
|
char *
|
|
canonicalize_file_name (const char * path)
|
|
{
|
|
#ifdef PATH_MAX
|
|
char *resolved_path = malloc (PATH_MAX+1);
|
|
if (resolved_path == NULL)
|
|
return NULL;
|
|
|
|
return realpath (path, resolved_path);
|
|
#else
|
|
#error undefined PATH_MAX _and_ missing canonicalize_file_name not supported
|
|
#endif
|
|
}
|