[BusyBox] make_directory

Vladimir N. Oleynik dzo at simtreas.ru
Thu Aug 1 08:45:05 UTC 2002


Glenn,
 
> I think the libbb make_directory function could be simpler, maybe
> something like.
> 
> void make_recursive_directory(char *path, mode_t mode)
> {
>         const char *path_ptr = strrchr(path, '/');
>         if (path_ptr) {

Not call mkdir() if not have '/'. Hmm, why?

>                 const char removed_char = *path_ptr;
>                 *path_ptr = '\0';

Warning - modyfy const ptr. ;)

>                 if ((mkdir(path, mode) == -1) && (errno == ENOENT)) {
>                         make_recursive_directory(path, mode);
>                         mkdir(path, mode);
>                 }
>                 *path_ptr = removed_char;

Warning - modyfy const ptr. ;)

May be remove all const keyword for compile without warning? ;)


--w
vodz



More information about the busybox mailing list