home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFILEMAN / XFILEMAN.TAR / xfilemanager / action_copy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  3.8 KB  |  170 lines

  1. /*
  2.  * Copyright 1993 by Ove Kalkan, Cremlingen, Germany
  3.  *
  4.  * Permission to use, copy, modify, distribute and sell this software and it's
  5.  * documentation for any purpose is hereby granted without fee, rpovided that
  6.  * the above copyright notice and this permission appear in supporting
  7.  * documentation, and that the name of Ove Kalkan not to be used in
  8.  * advertising or publicity pertaining to distributiopn of the software without
  9.  * specific, written prior permission. Ove Kalkan makes no representations
  10.  * about the suitability of this software for any purpose. It is provided
  11.  * as is without express or implied warranty.
  12.  *
  13.  * OVE KALKAN DISPLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  14.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABLILITY AND FITNESS, IN NO
  15.  * EVENT SHALL OVE KALKAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  16.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  17.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19.  * PERFORMANCE OF THIS SOFTWARE.
  20.  *
  21.  * $Header: filename,v 1.0 yyyy/mm/dd hh:mm:ss loginname Exp $
  22.  */
  23.  
  24.  
  25. #include "global.h"
  26.  
  27. /*
  28.  * Global variables
  29.  */
  30.  
  31.  
  32.  
  33. /*********************************************************
  34.  * name:    init_copy
  35.  * description:    erzeugt ein Fenster mit 2 texten zum kopieren
  36.  * input:    char *from, char *to;
  37.  * output:    none
  38.  * date:    10.5.93
  39.  *********************************************************/
  40. void    init_copy (char *from, char *to)
  41. {
  42.     Widget    but;
  43.  
  44.     /*
  45.      * Das Dialogfenster erzeugen
  46.      */
  47.     but = makeDialog(2,"From :","To   :",from,to,"Copy File",TRUE,FALSE,Icon_Copy_PM);
  48.  
  49.     XtAddCallback(but,XtNcallback,(XtCallbackProc) exec_copy_cb,NULL);
  50.  
  51.     /*
  52.      * Zum Schluss die Dialogshell managen
  53.      */
  54.     XtManageChild (dialog);
  55.  
  56.     /*
  57.      * Max und Minsize setzen
  58.      */
  59.     setSize();
  60. }
  61.  
  62.  
  63. /*********************************************************
  64.  * name:    exec_copy_cb
  65.  * description:    Kopieroperation ausfuehren
  66.  * input:    none
  67.  * output:    none
  68.  * date:    14.6.93
  69.  *********************************************************/
  70. void    exec_copy_cb (void)
  71. {
  72.     char    *from, *to;
  73.     Arg    args[1];
  74.     char    buf[1024];
  75.  
  76.     /*
  77.      * Die Texte der beiden Textfelder holen
  78.      */
  79.     XtSetArg(args[0],XtNstring,&from);
  80.     XtGetValues(text_1,args,1);
  81.  
  82.     XtSetArg(args[0],XtNstring,&to);
  83.     XtGetValues(text_2,args,1);
  84.  
  85.     /*
  86.      * Ueberpruefen ob in beiden ein Text steht, sonst
  87.      * Warnung ausgeben
  88.      */
  89.     if (!strlen(from) || !strlen(to)) {
  90.         WARNING ("Insuffisant Arguments.\nOperation aborted.");
  91.         return;
  92.     }
  93.     if (!MULTI)
  94.         exec_copy(from,to);
  95.     else {
  96.         char    *bot,*top;
  97.  
  98.         bot = from;
  99.         top = strchr(bot,'\n');
  100.         while (top) {
  101.             *top++ = '\0';
  102.             sprintf(buf,"%s %s %s\0",COPY_CMD,bot,to);
  103.  
  104.             system(buf);
  105.             bot = top;
  106.             top = strchr(bot,'\n');
  107.         }
  108.         /*
  109.          * Dialogfenster loeschen
  110.          */
  111.         if (dialog)
  112.             XtDestroyWidget(dialog);
  113.         dialog = NULL;
  114.  
  115.         /*
  116.          * Hier muss ein Update der veranderten Felder kommen
  117.          * Bisher unvollstaendig
  118.          */
  119. /*        multi_fo = NULL;
  120.         multi_vs = 16000;
  121.         multi_ve = 16000;
  122. */
  123.         /* Quellfolder oder Dir refreshen falls dargestellt */
  124.         refreshFolderByPathname (to);
  125. #ifdef    HAS_QUOTA
  126.         showQuota(quota_label);
  127. #endif
  128.         MULTI = FALSE;
  129.     }
  130. }
  131.  
  132.  
  133. /*********************************************************
  134.  * name:    exec_copy
  135.  * description:    Kopieroperation ausfuehren
  136.  * input:    none
  137.  * output:    none
  138.  * date:    14.6.93
  139.  *********************************************************/
  140. void    exec_copy (char *from, char *to)
  141. {
  142.     char    buf[1024];
  143.  
  144.     /*
  145.      * Befehl generieren und ausfuehren
  146.      */
  147.     sprintf(buf,"%s %s %s",COPY_CMD,from,to);
  148.     system(buf);
  149.     {
  150.         /*
  151.          * Dialogfenster loeschen
  152.          */
  153.         if (dialog)
  154.             XtDestroyWidget(dialog);
  155.         dialog = NULL;
  156.  
  157.         /*
  158.          * Hier muss ein Update der veranderten Felder kommen
  159.          * Bisher unvollstaendig
  160.          */
  161.         /* Zielfolder und Dir refreshen, falls vorhanden */
  162.         refreshFolderByPathname (to);
  163. #ifdef    HAS_QUOTA
  164.         showQuota(quota_label);
  165. #endif
  166.     }
  167. }
  168.  
  169.  
  170.