3
****************************************************************
4
* Copyright (C) 2002 Tom Lord
6
* See the file "COPYING" for further information about
7
* the copyright and warranty status of this work.
11
#include "hackerlab/bugs/panic.h"
12
#include "hackerlab/os/errno.h"
13
#include "hackerlab/os/unistd.h"
14
#include "hackerlab/char/str.h"
15
#include "hackerlab/fs/cwd.h"
20
safe_current_working_directory (void)
25
it = current_working_directory (&ign, 0);
27
panic ("unable to compute current working directory");
33
current_working_directory (int * errn, struct alloc_limits * limits)
39
path = lim_malloc (limits, sizeof_path);
45
lim_free (limits, path);
51
if (getcwd (path, sizeof_path))
54
answer = lim_realloc (limits, path, str_length (path) + 1);
59
else if (errno == ERANGE)
63
new_path = lim_realloc (limits, path, sizeof_path);
70
lim_free (limits, path);
78
/* tag: Tom Lord Fri Feb 22 04:10:53 2002 (cwd.c)