/* Programme qui ‚mule la commande copy de DOS avec r‚pertoire virtuel */ #include #include #include #include "ostool.h" #include "commun.h" #include #define PCOPY_VERSION 1 #define PCOPY_RELEASE 7 unsigned int _stklen = 20000; static void near usage(void) { static const char *tbf[]={ "pcopy [-s] [path/]fichiers ... [path/]destination", "copy avec r‚pertoire virtuel.", "\n", "-s : Copie silencieuse.", " Par d‚faut, affiche un message pour chaque", " fichier copi‚.", NULL }; version_usagef (tbf,tbf,"pcopy","pcopy" # if defined(VERSION_SHARE) ,&version_share # elif defined(VERSION_PROD) ,&version_prod # elif defined(VERSION_DEV) ,&version_beta # elif defined(VERSION_ESSAI) ,&version_alpha # endif ,PCOPY_VERSION,PCOPY_RELEASE ,1992,0,0 ,NULL,NULL,NULL); } static char silent=0; static int near pcopy_do ( const char *src, const char *dst, int dst_is_dir, // La destination est un r‚pertoire int ncopy) /* Utilise la commande de Novell pour */ /* Meilleure conservation des permissions (NFS) */ { char pathdst[MAXSIZ_PATH]; char pathsrc[MAXSIZ_PATH]; int ret = -1; if (dst_is_dir){ char nom[MAXSIZ_NAME]; path_splitlex (src,NULL,nom); path_make (dst,nom,pathdst); dst = pathdst; } if (vdir_exist (src,pathsrc) == 0){ error_bprintf ("Le fichier %s n'existe pas\n" ,"File %s does not exist\n",src); }else{ if (!silent) printf ("%s -> %s\n",pathsrc,dst); if (path_cmp(pathsrc,dst)==0){ error_bprintf ("Ne peut pas copier %s sur lui-mˆme\n" ,"Can't copy %s over itself\n",pathsrc); }else{ int nb_copy = 0; if (ncopy){ if (system_f ("ncopy %s %s",pathsrc,dst)==0){ nb_copy = 1; } }else{ nb_copy = file_copyp (pathsrc,dst); } if (nb_copy != 1){ error_bprintf ("Ne peut pas copier correctement\n" ,"Can't complete copy correctly\n"); }else{ ret = 0; } } } return ret; } static int near pcopy_dolist ( const char *wildsrc, const char *dest, int dest_is_dir, int ncopy) /* Utilise la commande de Novell pour */ /* Meilleure conservation des permissions (NFS) */ { int ret = -1; if (!dest_is_dir){ error_bprintf ("%s doit ˆtre un r‚pertoire\n" ,"%s must be a directory\n",dest); }else{ char *tb[1000]; int nb = vdir_getlistp (wildsrc,tb,1000); ret = 0; for (int i=0; i 2 && !dest_is_dir){ error_bprintf ("%s doit ˆtre un r‚pertoire\n" ,"%s must be a directory\n",dest); }else{ int ncopy = 0; #if 0 char path[MAXSIZ_PATH]; int ncopy = file_findexe ("ncopy",path) != -1; #endif ret = 0; for (int i=1; i