diff --git a/src/lib66/tree_copy.c b/src/lib66/tree_copy.c index 037dc8c70b167d518328a20992d957e8260de3ab..d14876f39b3c99d3903fe95c56187f8cd3f678f5 100644 --- a/src/lib66/tree_copy.c +++ b/src/lib66/tree_copy.c @@ -14,46 +14,31 @@ #include <66/tree.h> +#include <string.h> + #include <oblibs/string.h> #include <oblibs/directory.h> #include <oblibs/error2.h> -#include <string.h> - #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <66/constants.h> #include <66/utils.h> - +#include <stdio.h> int tree_copy(stralloc *dir, char const *tree,char const *treename) { - char *fdir = NULL ; - - - stralloc tmp = STRALLOC_ZERO ; - stralloc fdirtmp = STRALLOC_ZERO ; - - fdir = dir_create_tmp(&fdirtmp,"/tmp",treename) ; - if (!fdir) - { - VERBO3 strerr_warnwu1x("create tempory directory") ; - return 0 ; - } - if (!stralloc_cats(&tmp,tree)) retstralloc(0,"copy_tree") ; - if (!stralloc_cats(&tmp,SS_SVDIRS)) retstralloc(0,"copy_tree") ; - if (!stralloc_0(&tmp)) retstralloc(0,"copy_tree") ; + char *fdir = 0 ; + size_t treelen = strlen(tree) ; + char tmp[treelen + SS_SVDIRS_LEN + 1] ; + memcpy(tmp,tree,treelen) ; + memcpy(tmp + treelen,SS_SVDIRS,SS_SVDIRS_LEN) ; + tmp[treelen + SS_SVDIRS_LEN] = 0 ; - if (!hiercopy(tmp.s, fdir)) - { - VERBO3 strerr_warnwu2sys("to copy tree: ",tmp.s) ; - return 0 ; - } - if (!stralloc_cats(dir,fdir)) retstralloc(0,"copy_tree") ; - if (!stralloc_0(dir)) retstralloc(0,"copy_tree") ; + fdir = dir_create_tmp(dir,"/tmp",treename) ; + if (!fdir) return 0 ; - stralloc_free(&tmp) ; - stralloc_free(&fdirtmp) ; + if (!hiercopy(tmp,fdir)) return 0 ; return 1 ; }