sbase/util/agetcwd.c

21 lines
362 B
C
Raw Normal View History

2011-05-26 03:01:20 +00:00
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../util.h"
char *
agetcwd(void)
{
char *buf;
size_t size;
if((size = pathconf(".", _PC_PATH_MAX)) < 0)
size = BUFSIZ;
if(!(buf = malloc(size)))
eprintf("malloc:");
if(!getcwd(buf, size))
eprintf("getcwd:");
return buf;
}