[BusyBox] make_directory
Glenn McGrath
bug1 at optushome.com.au
Thu Aug 1 19:44:03 UTC 2002
On Thu, 01 Aug 2002 19:46:21 +0400
"Vladimir N. Oleynik" <dzo at simtreas.ru> wrote:
> Glenn,
>
> Ok. I rewrote and testing.
> Previous variant have bug, must rearrange lines.
>
Also you only need one return statment.
I think i was wrong in trying to get it to handle a path/file combination,
thats the job for basename().
int make_recursive_directory(char *path, mode_t mode)
{
char *pp;
int ret;
ret = mkdir(path, mode);
if (ret != 0 && errno == ENOENT &&
(pp = strrchr(path, '/'))!=NULL) {
*pp = '\0';
ret = make_recursive_directory(path, mode);
if(!ret) {
*pp = '/';
ret = mkdir(path, mode);
}
}
return ret;
}
Glenn
More information about the busybox
mailing list