blob: 0cf1825eacccfee9ba74f5c8a681721a7aebbc71 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* ISC license. */
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
int sarealpath (stralloc *sa, char const *path)
{
if (sa->s)
{
if (!stralloc_readyplus(sa, PATH_MAX)) return -1 ;
if (!realpath(path, sa->s + sa->len)) return -1 ;
sa->len += strlen(sa->s + sa->len) ;
}
else
{
char *p = realpath(path, 0) ;
if (!p) return -1 ;
sa->s = p ;
sa->len = strlen(p) ;
sa->a = sa->len + 1 ;
}
return 0 ;
}
|