blob: 0e316b20d6afcf95ce64d662f754d782485b2754 (
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
|
/* ISC license. */
#include <string.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, 128)) 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 ; /* XXX: incompatible with alloc() interposition */
sa->len = strlen(p) ;
sa->a = sa->len + 1 ;
}
return 0 ;
}
|