16 Dec
2009
16 Dec
'09
9:14 p.m.
On Wed, 2009-12-16 at 18:46 +0100, Marco Nenciarini wrote:
http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html */
BTW. That does getcwd() in a way too difficult way, at least for POSIX. This is what I used:
int t_get_current_dir(const char **dir_r) { /* @UNSAFE */ char *dir; size_t size = 128;
dir = t_buffer_get(size);
while (getcwd(dir, size) == NULL) {
if (errno != ERANGE)
return -1;
size = nearest_power(size+1);
dir = t_buffer_get(size);
}
t_buffer_alloc(strlen(dir) + 1);
*dir_r = dir;
return 0;
}