home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFILEMAN / XFILEMAN.TAR / xfilemanager / action_move.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  4.0 KB  |  172 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.  * name:    init_move
  33.  * description:    Files verschieben
  34.  * input:    char *from    - Quellfile
  35.  *        char *to    - Zielfile
  36.  * output:    none
  37.  * date:    10.6.93
  38.  *********************************************************/
  39. void    init_move (char *from, char *to)
  40. {
  41.     Widget    but;
  42.  
  43.     /*
  44.      * Das Dialogfenster erzeugen
  45.      */
  46.     but = makeDialog(2,"From :","To   :",from,to,"Moving & Renaming Files",TRUE,
  47.                 FALSE,Icon_Move_PM);
  48.  
  49.     XtAddCallback(but,XtNcallback,(XtCallbackProc) exec_move_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_move_cb
  65.  * description:    Ausfuehren der Verschiebeoperation
  66.  * input:    nichts
  67.  * output:    nichts
  68.  * date:    14.6.93
  69.  *********************************************************/
  70. void    exec_move_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_move(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",MOVE_CMD,bot,to);
  103.             system(buf);
  104.             bot = top;
  105.             top = strchr(bot,'\n');
  106.         }
  107.         /*
  108.          * Dialogfenster loeschen
  109.          */
  110.         if (dialog)
  111.             XtDestroyWidget(dialog);
  112.         dialog = NULL;
  113.  
  114.         /*
  115.          * Hier muss ein Update der veranderten Felder kommen
  116.          * Bisher unvollstaendig
  117.          */
  118.         bot = from;
  119.         multi_fo = NULL;
  120.         multi_vs = 16000;
  121.         multi_ve = 16000;
  122.         refreshFolderByPathname(bot);
  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.  * name:    exec_move
  134.  * description:    Ausfuehren der Verschiebeoperation
  135.  * input:    nichts
  136.  * output:    nichts
  137.  * date:    14.6.93
  138.  *********************************************************/
  139. void    exec_move (char *from, char *to)
  140. {
  141.     char    buf[1024];
  142.  
  143.     /*
  144.      * Befehl generieren und ausfuehren
  145.      */
  146.     sprintf(buf,"%s %s %s",MOVE_CMD,from,to);
  147.  
  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 oder Dir refreshen falls dargestellt */
  162.         refreshFolderByPathname (from);
  163.  
  164.         /* Quellfolder oder Dir refreshen falls dargestellt */
  165.         refreshFolderByPathname (to);
  166. #ifdef    HAS_QUOTA
  167.         showQuota(quota_label);
  168. #endif
  169.     }
  170. }
  171.  
  172.