Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtfile / OverWrite.c
1 /* $TOG: OverWrite.c /main/8 1998/10/26 12:40:12 mgreess $ */
2 /************************************<+>*************************************
3  ****************************************************************************
4  *
5  *   FILE:           OverWrite.c
6  *
7  *   COMPONENT_NAME: Desktop File Manager (dtfile)
8  *
9  *   Description:    Contains routines for collision dialog during
10  *                   move/copy/link operations.
11  *
12  *   FUNCTIONS: Create_Action_Area
13  *              buffer_multicollide_ok_callback
14  *              buffer_replace_rename_ok_callback
15  *              create_multicollide_dialog
16  *              create_replace_merge_dialog
17  *              create_replace_rename_dialog
18  *              getVariableMessage
19  *              multiRenameError_ok_callback
20  *              multiReplaceError_ok_callback
21  *              multicollide_cancel_callback
22  *              multicollide_ok_callback
23  *              renameError_ok_callback
24  *              replaceError_ok_callback
25  *              replace_merge_cancel_callback
26  *              replace_merge_ok_callback
27  *              replace_rename_cancel_callback
28  *              replace_rename_ok_callback
29  *              replace_rename_radio_callback
30  *
31  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
32  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
33  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
34  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
35  *
36  ****************************************************************************
37  ************************************<+>*************************************/
38
39 /* includes */
40 #include <errno.h>
41
42 #include <Xm/DialogS.h>
43 #include <Xm/Frame.h>
44 #include <Xm/Form.h>
45 #include <Xm/Label.h>
46 #include <Xm/PushB.h>
47 #include <Xm/RowColumn.h>
48 #include <Xm/ToggleB.h>
49 #include <Xm/TextF.h>
50 #include <Xm/Separator.h>
51
52
53 #include <Dt/DtNlUtils.h>
54
55 #include "Encaps.h"
56 #include "FileMgr.h"
57 #include "Desktop.h"
58 #include "Main.h"
59 #include "SharedProcs.h"
60 #include "Help.h"
61
62 #include "sharedFuncs.h"
63 #include "fsrtns.h"
64
65
66 /* defines */
67 #define VERTICAL_SPACING  5
68 #define HORIZONTAL_SPACING  10
69 #define TOP_SPACING  (VERTICAL_SPACING + 3)
70
71 /* types of messages sent through the pipe */
72 /* these messages are also defined & used in FileOp.c */
73 #define PIPEMSG_CANCEL      101
74 #define PIPEMSG_PROCEED     102
75 #define PIPEMSG_MERGE       103
76 #define PIPEMSG_REPLACE_BUFFER  104
77 #define PIPEMSG_RENAME_BUFFER   105
78 #define PIPEMSG_MULTI_PROCEED   106
79
80 #define RADIO_REPLACE 0
81 #define RADIO_RENAME  1
82
83
84 /* global variables */
85 Boolean G_initImages          = True;
86 int     G_filop_confirm_fd    = -1;
87 char    G_directory[MAX_PATH];
88 char    G_file[MAX_PATH];
89 String  *G_fileList           = NULL;
90 int     G_nCollisions         = 0;
91 Widget  G_dialogShell         = NULL;
92 Widget  G_rename_text         = NULL;
93 Widget  G_rename_toggle       = NULL;
94 Widget  G_merge_toggle        = NULL;
95 Widget  G_multi_rename_toggle = NULL;
96 int     G_mode;
97
98 /* types */
99 typedef enum {
100   vm_replaceCannotDeleteFolder,         /* 80 81 */
101   vm_replaceCannotDeleteFile,           /* 82 */
102   vm_multiCannotRenameMany,             /* 83 84 */
103   vm_multiCannotRenameOne,              /* 85 84 */
104   vm_multiCannotDeleteFolderMany,       /* 86 */
105   vm_multiCannotDeleteFolderOne,        /* 87 */
106   vm_multiCannotDeleteFileMany,         /* 88 */
107   vm_multiCannotDeleteFileOne          /* 89 */
108 } VariableMessage;
109
110 /* local functions */
111 static void      replaceError_ok_callback(
112                                     Widget w,
113                                     XtPointer client_data,
114                                     XtPointer call_data);
115 static void      renameError_ok_callback(
116                                     Widget w,
117                                     XtPointer client_data,
118                                     XtPointer call_data);
119 static void      multiReplaceError_ok_callback(
120                                     Widget w,
121                                     XtPointer client_data,
122                                     XtPointer call_data);
123 static void      multiRenameError_ok_callback(
124                                     Widget w,
125                                     XtPointer client_data,
126                                     XtPointer call_data);
127 static char *    getVariableMessage(
128                                     VariableMessage message,
129                                     int             mode);
130 static Boolean   IsReplaceable(
131                                     char *name);
132
133
134 /*--------------------------------------------------------------------
135  * Callback routines
136  *------------------------------------------------------------------*/
137
138
139 void
140 replace_rename_ok_callback(
141         Widget w,
142         XtPointer client_data,
143         XtPointer call_data)
144 {
145    const int    rc = PIPEMSG_PROCEED;
146    String       newFile, renameNewName, destinationName;
147    struct stat  buf;
148    int          saveError = 0;
149    static char  msg[30+(3*MAX_PATH)];
150    String       title;
151    char         *newFileDir = NULL;
152    char         *newFileName = NULL;
153    int          newFileDirLen;
154    int          rename_rc;
155    Boolean      same = (Boolean)client_data;
156
157    /* if same is true, then the object is tring to be copied into the same
158     * folder as itself.  So the existing files stay the same and the new files
159     * being created take on the new names.
160     */
161
162    /* Rename was selected */
163    if (XmToggleButtonGetState(G_rename_toggle))
164    {
165       newFile         = XmTextFieldGetString(G_rename_text);
166       renameNewName   = build_path(G_directory,newFile);
167       destinationName = build_path(G_directory,G_file);
168       XtFree(newFile);
169       /* make sure renameNewName does not exist */
170       if ( (lstat(renameNewName, &buf)) == 0)
171       {
172          sprintf(msg,
173                  GETMESSAGE(9, 38, "%s\nalready exists: choose another name."),
174                  renameNewName);
175          title = XtNewString(GETMESSAGE(9, 37, "Object Rename - Error"));
176          _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
177                            renameError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
178          XtFree(title);
179          XtFree(renameNewName);
180          XtFree(destinationName);
181          return;
182
183       }
184       if(!same)
185       {
186           /* attempt the rename ... since rename function is being used, this*/
187           /* only allows renames within the same filesystem */
188
189           DirectoryFileModified(home_host_name, G_directory, G_file);
190           if (DtStrchr(newFile, '/') == NULL)
191               DirectoryFileModified(home_host_name, G_directory, newFile);
192           else
193           {
194               newFileName = strrchr(renameNewName, '/');
195               newFileDirLen = newFileName - renameNewName;
196               newFileName++;
197
198               newFileDir = XtMalloc(newFileDirLen + 1);
199               strncpy(newFileDir, renameNewName, newFileDirLen);
200               newFileDir[newFileDirLen] = '\0';
201
202               DirectoryBeginModify(home_host_name, newFileDir);
203               DirectoryFileModified(home_host_name, newFileDir, newFileName);
204           }
205
206           errno = 0;
207           rename_rc = rename(destinationName, renameNewName);
208
209           if (newFileDir != NULL)
210           {
211               DirectoryEndModify(home_host_name, newFileDir);
212               XtFree(newFileDir);
213           }
214
215           if (rename_rc != 0)
216           {
217               saveError = errno;
218               sprintf(msg,
219                       GETMESSAGE(9, 39, "%s\ncannot be renamed to\n%s\n%s"),
220                       destinationName, renameNewName, strerror(saveError));
221               title = XtNewString(GETMESSAGE(9, 37, "Object Rename - Error"));
222               _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
223                                 renameError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
224               XtFree(title);
225               XtFree(renameNewName);
226               XtFree(destinationName);
227               return;
228           }
229       }
230       XtFree(renameNewName);
231       XtFree(destinationName);
232    }
233
234    /* Replace was selected ... remove the offending target */
235    else
236    {
237       destinationName = build_path(G_directory,G_file);
238       DirectoryFileModified(home_host_name, G_directory, G_file);
239       if(IsReplaceable(destinationName))
240         fsErase(destinationName,&saveError,False);
241       else
242         saveError = 1;
243       if ( saveError == 0 )
244       {
245          /* removal succeeded */
246          XtFree(destinationName);
247       }
248       else
249       {
250          /* removal failed */
251
252          stat(destinationName,&buf);
253          title = XtNewString(GETMESSAGE(9, 40, "Object Replace - Error"));
254
255          if (S_ISDIR(buf.st_mode))
256          {
257             strcpy(msg,getVariableMessage(vm_replaceCannotDeleteFolder, G_mode));
258          }
259          else
260          {
261             sprintf(msg,
262                     getVariableMessage(vm_replaceCannotDeleteFile, G_mode),
263                     destinationName);
264          }
265
266          _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
267                            replaceError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
268          XtFree(title);
269          XtFree(destinationName);
270          return;
271       }
272    }
273
274    /* close the dialog */
275    XtDestroyWidget(G_dialogShell);
276    G_dialogShell = NULL;
277
278    /* send return code through the pipe to the background proc */
279    write(G_filop_confirm_fd, &rc, sizeof(int));
280    G_filop_confirm_fd = -1;
281
282 }  /*  end replace_rename_ok_callback */
283
284
285 void
286 buffer_replace_rename_ok_callback(
287         Widget w,
288         XtPointer client_data,
289         XtPointer call_data)
290 {
291    int          rc = 0;
292    String       newFile, renameNewName, destinationName;
293    struct stat  buf;
294    int          saveError = 0;
295    static char  msg[38+MAX_PATH];
296    String       title;
297
298
299    /* Rename was selected */
300    if (XmToggleButtonGetState(G_rename_toggle))
301    {
302       newFile         = XmTextFieldGetString(G_rename_text);
303       renameNewName   = build_path(G_directory,newFile);
304       destinationName = build_path(G_directory,G_file);
305
306       /* make sure renameNewName does not exist */
307       if ( (lstat(renameNewName, &buf)) == 0)
308       {
309          sprintf(msg,
310                  GETMESSAGE(9, 38, "%s\nalready exists: choose another name."),
311                  renameNewName);
312          title = XtNewString(GETMESSAGE(9, 37, "Object Rename - Error"));
313          _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
314                            renameError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
315          XtFree(title);
316          XtFree(renameNewName);
317          XtFree(destinationName);
318          return;
319
320       }
321
322       /* Perform the actual rename in the child process */
323       /* set up pipe message */
324       rc = PIPEMSG_RENAME_BUFFER;
325
326
327       XtFree(renameNewName);
328       XtFree(destinationName);
329    }
330    /* Replace was selected ... remove the offending target */
331    else
332    {
333       destinationName = build_path(G_directory,G_file);
334       if(IsReplaceable(destinationName))
335         fsErase(destinationName,&saveError,False);
336       else
337         saveError = 1;
338       if ( saveError == 0 )
339       {
340
341          rc = PIPEMSG_REPLACE_BUFFER;
342          /* removal succeeded */
343          XtFree(destinationName);
344
345       }
346       else
347       {
348          /* removal failed */
349
350          stat(destinationName,&buf);
351          title = XtNewString(GETMESSAGE(9, 40, "Object Replace - Error"));
352
353          if (S_ISDIR(buf.st_mode))
354          {
355             strcpy(msg,getVariableMessage(vm_replaceCannotDeleteFolder, COPY_FILE));
356          }
357          else
358          {
359             sprintf(msg,
360                     getVariableMessage(vm_replaceCannotDeleteFile, COPY_FILE),
361                     destinationName);
362          }
363
364
365          _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
366                            replaceError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
367          XtFree(title);
368          XtFree(destinationName);
369          return;
370       }
371    }
372
373    /* close the dialog */
374    XtDestroyWidget(G_dialogShell);
375    G_dialogShell = NULL;
376
377    /* send return code through the pipe to the background proc */
378    write(G_filop_confirm_fd, &rc, sizeof(int));
379
380    /* write the the new name on the pipe if rename is selected */
381    if (XmToggleButtonGetState(G_rename_toggle))
382    {
383      DPRINTF(("Writing %s to %d\n", newFile ,G_filop_confirm_fd));
384      PipeWriteString(G_filop_confirm_fd, newFile);
385      XtFree(newFile);
386    }
387    G_filop_confirm_fd = -1;
388
389 }  /*  end buffer_replace_rename_ok_callback */
390
391
392 void
393 replace_rename_cancel_callback(
394         Widget w,
395         XtPointer client_data,
396         XtPointer call_data)
397 {
398    const int rc = PIPEMSG_CANCEL;
399
400    /* close the dialog */
401    XtDestroyWidget(G_dialogShell);
402    G_dialogShell = NULL;
403
404    /* send negative return code through the pipe to the background proc */
405    write(G_filop_confirm_fd, &rc, sizeof(int));
406    G_filop_confirm_fd = -1;
407
408 }  /*  end replace_rename_cancel_callback */
409
410
411 static void
412 replace_rename_radio_callback(
413         Widget w,
414         XtPointer client_data,
415         XtPointer call_data)
416 {
417    XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct *)call_data;
418
419
420    if (state->set)
421       switch ((int) client_data)
422       {
423         case RADIO_REPLACE:
424            XtVaSetValues (G_rename_text,
425                           XmNsensitive, FALSE,
426                           NULL);
427         break;
428
429         case RADIO_RENAME:
430            XtVaSetValues (G_rename_text,
431                           XmNsensitive, TRUE,
432                           NULL);
433            XmProcessTraversal(G_rename_text, XmTRAVERSE_CURRENT);
434         break;
435
436
437       }   /* end switch */
438
439   return;
440
441 }  /* end replace_rename_radio_callback */
442
443
444
445 static void
446 renameError_ok_callback(
447         Widget w,
448         XtPointer client_data,
449         XtPointer call_data)
450 {
451   XtDestroyWidget((Widget)client_data);
452   XmProcessTraversal(G_rename_text, XmTRAVERSE_CURRENT);
453
454   return;
455 }  /* end renameError_ok_callback */
456
457
458 void
459 replace_merge_ok_callback(
460         Widget w,
461         XtPointer client_data,
462         XtPointer call_data)
463 {
464    int          rc;
465    String       newFile=NULL, renameNewName, renameOldName;
466    struct stat  buf;
467    int          saveError = 0;
468    char         msg[128];
469    String       title;
470    char         *destinationPath =  build_path(G_directory,G_file);
471
472    if (XmToggleButtonGetState(G_merge_toggle))
473       rc = PIPEMSG_MERGE;
474    else
475    {
476       rc = PIPEMSG_PROCEED;
477       if(DirectoryBusy(destinationPath))
478       {
479          char *msg,*errmsg;
480
481          msg = GETMESSAGE(11,30, "Cannot move or rename the folder %s.\n\
482 All File Manager views displayed for a folder or its sub-folders\n\
483 must be closed before a folder can be moved or renamed.");
484
485          errmsg = XtMalloc(strlen(msg)+strlen(destinationPath)+1);
486          sprintf(errmsg,msg,destinationPath);
487          title = XtNewString(GETMESSAGE(9, 40, "Object Replace - Error"));
488          _DtMessage(toplevel, title, errmsg, NULL, HelpRequestCB);
489          XtFree(errmsg);
490          XtFree(title);
491          XtFree(destinationPath);
492          rc = PIPEMSG_CANCEL;
493       }
494    }
495
496    /* close the dialog */
497    XtDestroyWidget(G_dialogShell);
498    G_dialogShell = NULL;
499
500    /* send return code through the pipe to the background proc */
501    write(G_filop_confirm_fd, &rc, sizeof(int));
502    G_filop_confirm_fd = -1;
503
504 }  /*  end replace_merge_ok_callback */
505
506
507
508 void
509 replace_merge_cancel_callback(
510         Widget w,
511         XtPointer client_data,
512         XtPointer call_data)
513 {
514    const int rc = PIPEMSG_CANCEL;
515
516    /* close the dialog */
517    XtDestroyWidget(G_dialogShell);
518    G_dialogShell = NULL;
519
520    /* send negative return code through the pipe to the background proc */
521    write(G_filop_confirm_fd, &rc, sizeof(int));
522    G_filop_confirm_fd = -1;
523
524 }  /*  end replace_merge_cancel_callback */
525
526
527
528 void
529 multicollide_cancel_callback(
530         Widget w,
531         XtPointer client_data,
532         XtPointer call_data)
533 {
534    const int rc = PIPEMSG_CANCEL;
535    int       i;
536
537    /* close the dialog */
538    XtDestroyWidget(G_dialogShell);
539    G_dialogShell = NULL;
540
541    /* de-allocate the file list */
542    for ( i = 0; i < G_nCollisions; i++)
543       XtFree((char *)G_fileList[i]);
544    XtFree((char *)G_fileList);
545    G_fileList = NULL;
546
547    /* send return code through the pipe to the background proc */
548    write(G_filop_confirm_fd, &rc, sizeof(int));
549    G_filop_confirm_fd = -1;
550
551 }  /*  end multicollide_cancel_callback */
552
553
554 void
555 multicollide_ok_callback(
556         Widget w,
557         XtPointer client_data,
558         XtPointer call_data)
559 {
560    const int    rc = PIPEMSG_MULTI_PROCEED;
561    int          i;
562    int          saveError;
563    String       destinationPath;
564    String       title;
565    static char  msg[1024];
566    struct stat  buf;
567
568
569    Boolean      same = (Boolean)client_data;
570
571    /* if same is true, then the object is tring to be copied into the same
572     * folder as itself.  So the existing files stay the same and the new files
573     * being created take on the new names.
574     */
575
576    if (XmToggleButtonGetState(G_multi_rename_toggle))
577    {
578       char *names = NULL;
579       title = XtNewString(GETMESSAGE(9, 37, "Object Rename - Error"));
580
581       write(G_filop_confirm_fd, &rc, sizeof(int));
582       /* Auto rename was selected */
583       for ( i = 0; i < G_nCollisions; i++)
584       {
585           if(!same)
586           {
587
588          destinationPath = build_path(G_directory,G_fileList[i]);
589          DirectoryFileModified(home_host_name, G_directory, G_fileList[i]);
590          if ( auto_rename(destinationPath) != 0)
591          {
592            saveError = -1;
593            if(!names)
594              names = (char *) XtNewString(destinationPath);
595            else
596            {
597              names = (char *)XtRealloc(names,strlen(names)+
598                               strlen(destinationPath)+2);
599              strcat(names,"\n");
600              strcat(names,destinationPath);
601            }
602          }
603          else
604            saveError = 0;
605          write(G_filop_confirm_fd, &saveError, sizeof(int));
606          XtFree(destinationPath);
607       }
608
609           else
610           {
611               saveError = 0;
612               write(G_filop_confirm_fd, &saveError, sizeof(int));
613           }
614       }
615
616       if(!same)
617       {
618           if ( names )
619           {
620               char *buf;
621               int bufsize;
622               buf = XtMalloc(strlen(GETMESSAGE(9,138, "Failed to rename the following object(s)\n\n%s\n\nThe most likely cause is that you do not have\npermission to rename these objects(s)"))+strlen(names)+10);
623               sprintf(buf,GETMESSAGE(9,138, "Failed to rename the following object(s)\n\n%s\n\nThe most likely cause is that you do not have\npermission to rename these object(s)"),names);
624               _DtMessage(toplevel, title, buf, NULL, HelpRequestCB);
625               XtFree(buf);
626           }
627           XtFree(names);
628       }
629       XtFree(title);
630    }
631    else
632    {
633       char *names = NULL;
634
635       title = XtNewString(GETMESSAGE(9, 40, "Object Replace - Error"));
636       write(G_filop_confirm_fd, &rc, sizeof(int));
637
638       /* Replace was selected ... remove the offending targets */
639       for ( i = 0; i < G_nCollisions; i++)
640       {
641          destinationPath = build_path(G_directory,G_fileList[i]);
642          if(IsReplaceable(destinationPath))
643          {
644            if(DirectoryBusy(destinationPath))
645            {
646              char *msg,*errmsg;
647
648              msg = GETMESSAGE(11,30, "Cannot move or rename the folder%s.\nAll File Manager views displayed for a folder or its sub-folders\nmust be closed before a folder can be moved or renamed.");
649
650              errmsg = XtMalloc(strlen(msg)+strlen(destinationPath)+1);
651              sprintf(errmsg,msg,destinationPath);
652              _DtMessage(toplevel, title, errmsg, NULL, HelpRequestCB);
653              XtFree(errmsg);
654              XtFree(destinationPath);
655              continue;
656            }
657            else
658              fsErase(destinationPath,&saveError,False);
659          }
660          else
661            saveError = -1;
662          write(G_filop_confirm_fd, &saveError, sizeof(int));
663          if(saveError != 0)
664          {
665            if(!names)
666              names = (char *) XtNewString(destinationPath);
667            else
668            {
669              names = (char *)XtRealloc(names,strlen(names)+
670                               strlen(destinationPath)+2);
671              strcat(names,"\n");
672              strcat(names,destinationPath);
673            }
674          }
675          XtFree(destinationPath);
676       }
677       if ( names )
678       {
679         char *buf;
680         int bufsize;
681         buf = XtMalloc(strlen(GETMESSAGE(9,139, "Failed to replace the following object(s)\n\n%s\n\nThe most likely cause is that you do not have\npermission to replace these object(s)"))+strlen(names)+10);
682         sprintf(buf,GETMESSAGE(9,139, "Failed to replace the following object(s)\n\n%s\n\nThe most likely cause is that you do not have\npermission to replace these object(s)"),names);
683         _DtMessage(toplevel, title, buf, NULL, HelpRequestCB);
684         XtFree(buf);
685       }
686       XtFree(names);
687       XtFree(title);
688    }
689
690
691    /* close the dialog */
692    XtDestroyWidget(G_dialogShell);
693    G_dialogShell = NULL;
694
695    /* de-allocate the file list */
696    for ( i = 0; i < G_nCollisions; i++)
697       XtFree((char *)G_fileList[i]);
698    XtFree((char *)G_fileList);
699    G_fileList = NULL;
700
701    /* send return code through the pipe to the background proc */
702 /*
703    write(G_filop_confirm_fd, &rc, sizeof(int));
704 */
705    G_filop_confirm_fd = -1;
706 }  /*  end multicollide_ok_callback */
707
708
709 void
710 buffer_multicollide_ok_callback(
711         Widget w,
712         XtPointer client_data,
713         XtPointer call_data)
714 {
715    int          rc = 0;
716    int          i;
717    int          saveError;
718    String       destinationPath;
719    String       title;
720    char         newPath[MAX_PATH];
721    char         *newFile;
722    static char  msg[1024];
723    struct stat  buf;
724
725
726    if (XmToggleButtonGetState(G_multi_rename_toggle))
727    {
728      /* send return code through the pipe to the background proc */
729       rc = PIPEMSG_RENAME_BUFFER;
730       write(G_filop_confirm_fd, &rc, sizeof(int));
731
732       /* Auto rename was selected */
733       for ( i = 0; i < G_nCollisions; i++)
734       {
735          /* automatically generated new name */
736          destinationPath = build_path(G_directory,G_fileList[i]);
737          generate_NewPath(newPath, destinationPath);
738          newFile= strrchr(newPath,'/') + 1 ;
739
740          DPRINTF (("buffer_multicollide_ok_callback: new file is %s\n", newFile));
741
742          /* write new name on the pipe */
743
744          PipeWriteString(G_filop_confirm_fd, newFile);
745
746          XtFree(destinationPath);
747       }
748    } /* endif multi auto-rename */
749    else
750    {
751       title = XtNewString(GETMESSAGE(9, 40, "Object Replace - Error"));
752
753       /* Replace was selected ... remove the offending targets */
754       for ( i = 0; i < G_nCollisions; i++)
755       {
756          /* set the pipe msg */
757          rc = PIPEMSG_REPLACE_BUFFER;
758
759          destinationPath = build_path(G_directory,G_fileList[i]);
760          fsErase(destinationPath,&saveError,False);
761          if ( saveError != 0 )
762          {
763             /* removal failed */
764             stat(destinationPath,&buf);
765
766             if ( S_ISDIR(buf.st_mode) && i != 1 )
767             {
768                sprintf(msg,
769                        getVariableMessage(vm_multiCannotDeleteFolderMany, COPY_FILE),
770                        destinationPath, i);
771             }
772             else if ( S_ISDIR(buf.st_mode) && i == 1)
773             {
774                sprintf(msg,
775                        getVariableMessage(vm_multiCannotDeleteFolderOne, COPY_FILE),
776                        destinationPath);
777             }
778             else if ( ! S_ISDIR(buf.st_mode) && i != 1 )
779             {
780                sprintf(msg,
781                        getVariableMessage(vm_multiCannotDeleteFileMany, COPY_FILE),
782                        destinationPath, i);
783             }
784             else  /*  ! S_ISDIR(buf.st_mode) && i == 1 ) */
785             {
786                sprintf(msg,
787                        getVariableMessage(vm_multiCannotDeleteFileOne, COPY_FILE),
788                        destinationPath);
789             }
790             _DtMessageDialog (G_dialogShell, title, msg, 0, FALSE, NULL,
791                               multiReplaceError_ok_callback, NULL, NULL, False, ERROR_DIALOG);
792             XtFree(destinationPath);
793             return;
794          }
795
796
797          /* send return code through the pipe to the background proc */
798          rc = PIPEMSG_REPLACE_BUFFER;
799          write(G_filop_confirm_fd, &rc, sizeof(int));
800
801          XtFree(destinationPath);
802       }
803       XtFree(title);
804    } /* end else */
805
806
807    /* close the dialog */
808    XtDestroyWidget(G_dialogShell);
809    G_dialogShell = NULL;
810
811    /* de-allocate the file list */
812    for ( i = 0; i < G_nCollisions; i++)
813       XtFree((char *)G_fileList[i]);
814    XtFree((char *)G_fileList);
815    G_fileList = NULL;
816
817    G_filop_confirm_fd = -1;
818
819 }  /*  end multicollide_ok_callback */
820
821
822
823 static void
824 replaceError_ok_callback(
825         Widget w,
826         XtPointer client_data,
827         XtPointer call_data)
828 {
829   XtDestroyWidget((Widget)client_data);
830
831   return;
832 }  /* end replaceError_ok_callback */
833
834
835
836 static void
837 multiReplaceError_ok_callback(
838         Widget w,
839         XtPointer client_data,
840         XtPointer call_data)
841 {
842   XtDestroyWidget((Widget)client_data);
843
844   return;
845 }  /* end multiReplaceError_ok_callback */
846
847
848
849 static void
850 multiRenameError_ok_callback(
851         Widget w,
852         XtPointer client_data,
853         XtPointer call_data)
854 {
855   XtDestroyWidget((Widget)client_data);
856
857   return;
858 }  /* end multiRenameError_ok_callback */
859
860
861
862 /*--------------------------------------------------------------------
863  * create replace/rename dialog
864  *------------------------------------------------------------------*/
865
866 void
867 create_replace_rename_dialog(Widget         parent_widget,
868                              int            mode,
869                              String         directory,
870                              String         file,
871                              int            filop_confirm_fd,
872                              ActionAreaDefn actions,
873                              Boolean        Same)
874 {
875   Arg args[10];
876   int n;
877   Widget form;
878   Widget icon;
879   Widget action_label;
880   Widget msg_label;
881   Widget radio;
882   Widget radioButton1;
883   Widget actionArea;
884   Widget separator;
885   Pixmap px;
886   Pixel background, foreground;
887   char     path[MAX_PATH], newDir[MAX_PATH], newFile[MAX_PATH];
888   String   s;
889   XmString xs;
890   char *title;
891   char *orig_label;
892   int orig_msg_num;
893   Boolean set;
894
895   if( G_dialogShell )
896   {
897      XBell( XtDisplay( G_dialogShell ), 100 );
898      return;
899   }
900
901   /* make args available to callback functions */
902   G_filop_confirm_fd = filop_confirm_fd;
903   G_mode             = mode;
904   strcpy(G_directory,directory);
905   strcpy(G_file,file);
906
907   /* Initialize images for error, warning, ... icons */
908   if (G_initImages)
909   {
910      ImageInitialize(XtDisplay(toplevel));
911      G_initImages = False;
912   }
913
914   /* Initialize mode-dependent things */
915   n = 0;
916   orig_label = actions.actionList[1].label;
917   orig_msg_num = actions.actionList[1].msg_num;
918   switch (mode) {
919      case MOVE_FILE:
920         title = XtNewString(GETMESSAGE(9, 34, "File Manager - Move Warning"));
921         XtSetArg (args[n], XmNtitle, title);
922         n++;
923         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 30, "Cancel Move"));
924         actions.actionList[1].msg_num = 30;
925         break;
926      case COPY_FILE:
927         title = XtNewString(GETMESSAGE(9, 35, "File Manager - Copy Warning"));
928         XtSetArg (args[n], XmNtitle, title);
929         n++;
930         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 31, "Cancel Copy"));
931         actions.actionList[1].msg_num = 31;
932         break;
933      case LINK_FILE:
934         title = XtNewString(GETMESSAGE(9, 36, "File Manager - Link Warning"));
935         XtSetArg (args[n], XmNtitle, title);
936         n++;
937         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 32, "Cancel Link"));
938         actions.actionList[1].msg_num = 32;
939         break;
940      default:
941         title = XtNewString(GETMESSAGE(9, 33, "File Manager - Move/Copy/Link Warning"));
942         XtSetArg (args[n], XmNtitle, title);
943         n++;
944         break;
945   }
946
947
948   /* Create the dialog shell for the dialog */
949   G_dialogShell = XmCreateDialogShell (parent_widget, "replace/rename dialog", args, n);
950
951
952   /* Create the Manager Widget, form, for the copy dialog */
953   form  = XtVaCreateWidget ("dialog_form",
954                              xmFormWidgetClass,  G_dialogShell,
955                              XmNverticalSpacing,   VERTICAL_SPACING,
956                              XmNhorizontalSpacing, HORIZONTAL_SPACING,
957                              XmNdialogStyle,       XmDIALOG_FULL_APPLICATION_MODAL,
958                              NULL);
959
960   /* Create a question dialog icon */
961   n = 0;
962   XtSetArg (args[n], XmNbackground, &background); n++;
963   XtSetArg (args[n], XmNforeground, &foreground); n++;
964   XtGetValues (form, args, n);
965
966   px = XmGetPixmapByDepth(XtScreen(form), "xm_question",
967                           foreground, background, form->core.depth);
968   if (px == XmUNSPECIFIED_PIXMAP)
969     px = XmGetPixmapByDepth(XtScreen(form), "default_xm_question",
970                      foreground, background, form->core.depth);
971
972   icon = XtVaCreateManagedWidget("question_icon",
973                              xmLabelWidgetClass, form,
974                              XmNlabelType,        XmPIXMAP,
975                              XmNlabelPixmap,      px,
976                              XmNtopAttachment,    XmATTACH_FORM,
977                              XmNleftAttachment,   XmATTACH_FORM,
978                              NULL);
979
980   /* Create the message label */
981   s = XtMalloc( 1
982                 + strlen( GETMESSAGE(9, 16, "An object named\n%s\nalready exists inside the folder\n%s") )
983                 + strlen( file )
984                 + strlen( directory ) );
985   sprintf( s,
986            GETMESSAGE(9, 16, "An object named\n%s\nalready exists inside the folder\n%s"),
987            file,
988            directory );
989
990   xs = XmStringCreateLocalized(s);
991   msg_label = XtVaCreateManagedWidget("msg_header",
992                              xmLabelWidgetClass, form,
993                              XmNlabelString,      xs,
994                              XmNalignment,        XmALIGNMENT_BEGINNING,
995                              XmNtopAttachment,    XmATTACH_FORM,
996                              XmNleftAttachment,   XmATTACH_WIDGET,
997                              XmNleftWidget,       icon,
998                              XmNleftOffset,       HORIZONTAL_SPACING,
999                              XmNrightAttachment,  XmATTACH_FORM,
1000                              NULL);
1001   XmStringFree(xs);
1002   XtFree(s);
1003
1004
1005   /* create the action-question */
1006   xs = XmStringCreateLocalized(GETMESSAGE(9, 20, "What do you want to do?"));
1007   action_label = XtVaCreateManagedWidget("action-question",
1008                              xmLabelWidgetClass, form,
1009                              XmNlabelString,      xs,
1010                              XmNalignment,        XmALIGNMENT_BEGINNING,
1011                              XmNtopAttachment,    XmATTACH_WIDGET,
1012                              XmNtopWidget,        msg_label,
1013                              XmNtopOffset,        3*VERTICAL_SPACING,
1014                              XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET,
1015                              XmNleftWidget,       msg_label,
1016                              XmNleftOffset,       0,
1017                              NULL);
1018   XmStringFree(xs);
1019
1020   /* create radio box */
1021
1022   n = 0;
1023   XtSetArg (args[n], XmNorientation,      XmVERTICAL);               n++;
1024   XtSetArg (args[n], XmNtopAttachment,    XmATTACH_WIDGET);          n++;
1025   XtSetArg (args[n], XmNtopWidget,        action_label);             n++;
1026   XtSetArg (args[n], XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET); n++;
1027   XtSetArg (args[n], XmNleftWidget,       action_label);             n++;
1028   XtSetArg (args[n], XmNleftOffset,       2*HORIZONTAL_SPACING);     n++;
1029   radio = (Widget) XmCreateRadioBox(form, "radio_box", args, n);
1030
1031   if( mode == MAKE_BUFFER )
1032     set = FALSE;
1033   else
1034   {
1035       /* if the object is have the operation done to the same folder (i.e.
1036          being done to itself, we want the default to be to create a new name
1037          for the new object.
1038          */
1039       if(Same)
1040           set = FALSE;
1041       else
1042     set = TRUE;
1043   }
1044
1045   /* create the radio buttons ... default button is replace */
1046   xs = XmStringCreateLocalized(GETMESSAGE(9, 21, "Replace existing object"));
1047   radioButton1 = XtVaCreateManagedWidget("radio_toggle1",
1048                                          xmToggleButtonWidgetClass, radio,
1049                                          XmNalignment,   XmALIGNMENT_BEGINNING,
1050                                          XmNlabelString, xs,
1051                                          XmNset,         set,
1052                                          NULL);
1053   XmStringFree(xs);
1054   if(!Same)
1055   {
1056       XtSetSensitive(radioButton1, True);
1057       XtAddCallback(radioButton1, XmNvalueChangedCallback, replace_rename_radio_callback, (XtPointer) RADIO_REPLACE);
1058   }
1059   else
1060       XtSetSensitive(radioButton1, False);
1061
1062   if( mode == MAKE_BUFFER )
1063   {
1064     xs = XmStringCreateLocalized(GETMESSAGE(10,48, "New Object Name:"));
1065     set = TRUE;
1066   }
1067   else
1068   {
1069       if(Same)
1070       {
1071           xs = XmStringCreateLocalized(GETMESSAGE(9, 140, "Rename new object to:"));
1072           set = TRUE;
1073       }
1074       else
1075       {
1076           xs = XmStringCreateLocalized(GETMESSAGE(9, 22, "Rename existing object to:"));
1077           set = FALSE;
1078       }
1079   }
1080   G_rename_toggle = XtVaCreateManagedWidget("radio_toggle2",
1081                                             xmToggleButtonWidgetClass, radio,
1082                                             XmNalignment,   XmALIGNMENT_BEGINNING,
1083                                             XmNlabelString, xs,
1084                                             XmNset,         set,
1085                                             NULL);
1086   XmStringFree(xs);
1087   XtAddCallback(G_rename_toggle, XmNvalueChangedCallback, replace_rename_radio_callback, (XtPointer) RADIO_RENAME);
1088
1089   XtManageChild(radio);
1090
1091
1092   /* create text field for entering a new file name */
1093   /* a name is generated to use as the default */
1094   _DtBuildPath(path,directory,file);
1095   generate_NewPath(path,path);
1096   split_path(path, newDir, newFile);
1097   G_rename_text = XtVaCreateManagedWidget("rename_text",
1098                                        xmTextFieldWidgetClass, form,
1099                                        XmNrightAttachment,  XmATTACH_FORM,
1100                                        XmNleftAttachment,   XmATTACH_WIDGET,
1101                                        XmNleftWidget,       radio,
1102                                        XmNleftOffset,       HORIZONTAL_SPACING,
1103                                        XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
1104                                        XmNbottomWidget,     radio,
1105                                        XmNsensitive,        set,
1106                                        XmNvalue,            newFile,
1107                                        XmNcursorPosition,   strlen(newFile),
1108                                        NULL);
1109
1110   /* create the action area  */
1111   actionArea = Create_Action_Area(form, actions,  NULL);
1112   separator  =  XtVaCreateManagedWidget("separator",
1113                                         xmSeparatorWidgetClass, form,
1114                                         XmNtopAttachment,     XmATTACH_WIDGET,
1115                                         XmNtopWidget,         radio,
1116                                         XmNbottomAttachment,  XmATTACH_WIDGET,
1117                                         XmNbottomWidget,      actionArea,
1118                                         XmNleftAttachment,    XmATTACH_FORM,
1119                                         XmNrightAttachment,   XmATTACH_FORM,
1120                                         NULL);
1121
1122
1123   /* set initial keyborad focus to the action button area */
1124   XtVaSetValues(form,
1125                 XmNinitialFocus, actionArea,
1126                 NULL);
1127
1128   /* Manage the dialog */
1129   XtManageChild(form);
1130
1131
1132   XtFree(title);
1133   XtFree(actions.actionList[1].label);
1134   actions.actionList[1].label = orig_label;
1135   actions.actionList[1].msg_num = orig_msg_num;
1136   return;
1137
1138 }  /* end create_replace_rename_dialog */
1139
1140
1141
1142 /*--------------------------------------------------------------------
1143  * create replace/merge dialog
1144  *------------------------------------------------------------------*/
1145
1146 void
1147 create_replace_merge_dialog(Widget parent_widget,
1148                              int            mode,
1149                              String         directory,
1150                              String         file,
1151                              int            filop_confirm_fd,
1152                              ActionAreaDefn actions)
1153 {
1154   Arg args[10];
1155   int n;
1156   Widget form;
1157   Widget icon;
1158   Widget action_label;
1159   Widget msg_label;
1160   Widget radio;
1161   Widget radioButton1;
1162   Widget actionArea;
1163   Widget separator;
1164   Pixmap px;
1165   Pixel background, foreground;
1166   char     path[MAX_PATH], newDir[MAX_PATH], newFile[MAX_PATH];
1167   String   s;
1168   XmString xs;
1169   char *title;
1170   char *orig_label;
1171   int orig_msg_num;
1172
1173   if( G_dialogShell )
1174   {
1175      XBell( XtDisplay( G_dialogShell ), 100 );
1176      return;
1177   }
1178
1179   /* make args available to callback functions */
1180   G_filop_confirm_fd = filop_confirm_fd;
1181   G_mode             = mode;
1182   strcpy(G_directory,directory);
1183   strcpy(G_file,file);
1184
1185   /* Initialize images for error, warning, ... icons */
1186   if (G_initImages)
1187   {
1188      ImageInitialize(XtDisplay(toplevel));
1189      G_initImages = False;
1190   }
1191
1192   /* Initialize mode-dependent things */
1193   n = 0;
1194   orig_label = actions.actionList[1].label;
1195   orig_msg_num = actions.actionList[1].msg_num;
1196   switch (mode) {
1197      case MOVE_FILE:
1198         title = XtNewString(GETMESSAGE(9, 34, "File Manager - Move Warning"));
1199         XtSetArg (args[n], XmNtitle, title);
1200         n++;
1201         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 30, "Cancel Move"));
1202         actions.actionList[1].msg_num = 30;
1203         break;
1204      case COPY_FILE:
1205         title = XtNewString(GETMESSAGE(9, 35, "File Manager - Copy Warning"));
1206         XtSetArg (args[n], XmNtitle, title);
1207         n++;
1208         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 31, "Cancel Copy"));
1209         actions.actionList[1].msg_num = 31;
1210         break;
1211      case LINK_FILE:
1212         title = XtNewString(GETMESSAGE(9, 36, "File Manager - Link Warning"));
1213         XtSetArg (args[n], XmNtitle, title);
1214         n++;
1215         actions.actionList[1].label   = XtNewString(GETMESSAGE(9, 32, "Cancel Link"));
1216         actions.actionList[1].msg_num = 32;
1217         break;
1218      default:
1219         title = XtNewString(GETMESSAGE(9, 33, "File Manager - Move/Copy/Link Warning"));
1220         XtSetArg (args[n], XmNtitle, title);
1221         n++;
1222         break;
1223   }
1224
1225
1226   /* Create the dialog shell for the dialog */
1227   G_dialogShell = XmCreateDialogShell (parent_widget, "replace/merge dialog", args, n);
1228
1229
1230   /* Create the Manager Widget, form, for the copy dialog */
1231   form  = XtVaCreateWidget ("dialog_form",
1232                              xmFormWidgetClass,  G_dialogShell,
1233                              XmNverticalSpacing,   VERTICAL_SPACING,
1234                              XmNhorizontalSpacing, HORIZONTAL_SPACING,
1235                              XmNdialogStyle,       XmDIALOG_FULL_APPLICATION_MODAL,
1236                              NULL);
1237
1238   /* Create a question dialog icon */
1239   n = 0;
1240   XtSetArg (args[n], XmNbackground, &background); n++;
1241   XtSetArg (args[n], XmNforeground, &foreground); n++;
1242   XtGetValues (form, args, n);
1243
1244   px = XmGetPixmapByDepth(XtScreen(form), "xm_question",
1245                           foreground, background, form->core.depth);
1246   if (px == XmUNSPECIFIED_PIXMAP)
1247     px = XmGetPixmapByDepth(XtScreen(form), "default_xm_question",
1248                      foreground, background, form->core.depth);
1249
1250   icon = XtVaCreateManagedWidget("question_icon",
1251                              xmLabelWidgetClass, form,
1252                              XmNlabelType,        XmPIXMAP,
1253                              XmNlabelPixmap,      px,
1254                              XmNtopAttachment,    XmATTACH_FORM,
1255                              XmNleftAttachment,   XmATTACH_FORM,
1256                              NULL);
1257
1258   /* Create the message label */
1259   s = XtMalloc( 1
1260                 + strlen( GETMESSAGE(9, 17, "A folder named\n%s\nalready exists inside the folder\n%s") )
1261                 + strlen( file )
1262                 + strlen( directory ) );
1263
1264   sprintf(s, GETMESSAGE(9, 17, "A folder named\n%s\nalready exists inside the folder\n%s"), file, directory);
1265
1266   xs = XmStringCreateLocalized(s);
1267   msg_label = XtVaCreateManagedWidget("msg_header",
1268                              xmLabelWidgetClass, form,
1269                              XmNlabelString,      xs,
1270                              XmNalignment,        XmALIGNMENT_BEGINNING,
1271                              XmNtopAttachment,    XmATTACH_FORM,
1272                              XmNleftAttachment,   XmATTACH_WIDGET,
1273                              XmNleftWidget,       icon,
1274                              XmNleftOffset,       HORIZONTAL_SPACING,
1275                              XmNrightAttachment,  XmATTACH_FORM,
1276                              NULL);
1277   XmStringFree(xs);
1278   XtFree(s);
1279
1280
1281   /* create the action-question */
1282   xs = XmStringCreateLocalized(GETMESSAGE(9, 20, "What do you want to do?"));
1283   action_label = XtVaCreateManagedWidget("action-question",
1284                              xmLabelWidgetClass, form,
1285                              XmNlabelString,      xs,
1286                              XmNalignment,        XmALIGNMENT_BEGINNING,
1287                              XmNtopAttachment,    XmATTACH_WIDGET,
1288                              XmNtopWidget,        msg_label,
1289                              XmNtopOffset,        3*VERTICAL_SPACING,
1290                              XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET,
1291                              XmNleftWidget,       msg_label,
1292                              XmNleftOffset,       0,
1293                              NULL);
1294   XmStringFree(xs);
1295
1296   /* create radio box */
1297
1298   n = 0;
1299   XtSetArg (args[n], XmNorientation,      XmVERTICAL);               n++;
1300   XtSetArg (args[n], XmNtopAttachment,    XmATTACH_WIDGET);          n++;
1301   XtSetArg (args[n], XmNtopWidget,        action_label);             n++;
1302   XtSetArg (args[n], XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET); n++;
1303   XtSetArg (args[n], XmNleftWidget,       action_label);             n++;
1304   XtSetArg (args[n], XmNleftOffset,       2*HORIZONTAL_SPACING);     n++;
1305   radio = (Widget) XmCreateRadioBox(form, "radio_box", args, n);
1306
1307   /* create the radio buttons ... default button is replace */
1308   xs = XmStringCreateLocalized(GETMESSAGE(9, 25, "Replace existing folder"));
1309   radioButton1 = XtVaCreateManagedWidget("radio_toggle1",
1310                                          xmToggleButtonWidgetClass, radio,
1311                                          XmNalignment,   XmALIGNMENT_BEGINNING,
1312                                          XmNlabelString, xs,
1313                                          XmNset,         TRUE,
1314                                          NULL);
1315   XmStringFree(xs);
1316
1317   xs = XmStringCreateLocalized(GETMESSAGE(9, 24, "Merge contents of the two folders"));
1318   G_merge_toggle = XtVaCreateManagedWidget("radio_toggle2",
1319                                             xmToggleButtonWidgetClass, radio,
1320                                             XmNalignment,   XmALIGNMENT_BEGINNING,
1321                                             XmNlabelString, xs,
1322                                             NULL);
1323   XmStringFree(xs);
1324
1325   XtManageChild(radio);
1326
1327
1328   /* create the action area  */
1329   actionArea = Create_Action_Area(form, actions, NULL);
1330   separator  =  XtVaCreateManagedWidget("separator",
1331                                         xmSeparatorWidgetClass, form,
1332                                         XmNtopAttachment,     XmATTACH_WIDGET,
1333                                         XmNtopWidget,         radio,
1334                                         XmNbottomAttachment,  XmATTACH_WIDGET,
1335                                         XmNbottomWidget,      actionArea,
1336                                         XmNleftAttachment,    XmATTACH_FORM,
1337                                         XmNrightAttachment,   XmATTACH_FORM,
1338                                         NULL);
1339
1340
1341   /* set initial keyborad focus to the action button area */
1342   XtVaSetValues(form,
1343                 XmNinitialFocus, actionArea,
1344                 NULL);
1345
1346   /* Manage the dialog */
1347   XtManageChild(form);
1348
1349
1350   XtFree(title);
1351   XtFree(actions.actionList[1].label);
1352   actions.actionList[1].label = orig_label;
1353   actions.actionList[1].msg_num = orig_msg_num;
1354   return;
1355
1356 }  /* end create_replace_merge_dialog */
1357
1358
1359
1360
1361 /*--------------------------------------------------------------------
1362  * create multicollide dialog
1363  *------------------------------------------------------------------*/
1364
1365 void
1366 create_multicollide_dialog(Widget           parent_widget,
1367                            int              mode,
1368                            int              nSelected,
1369                            int              nCollisions,
1370                            String           destination,
1371                            String         * fileList,
1372                            int              filop_confirm_fd,
1373                            ActionAreaDefn   actions,
1374                            Boolean          Same)
1375 {
1376   Arg args[10];
1377   int n;
1378   Widget form;
1379   Widget icon;
1380   Widget action_label;
1381   Widget msg_label;
1382   Widget radio;
1383   Widget radioButton1;
1384   Widget actionArea;
1385   Widget separator;
1386   Pixmap px;
1387   Pixel background, foreground;
1388   String   s, s1, eMsgOne, eMsgMany;
1389   int nChanged;
1390   XmString xs;
1391   char *title;
1392   char *orig_label;
1393   int orig_msg_num;
1394   Boolean set;
1395
1396   if( G_dialogShell )
1397   {
1398      XBell( XtDisplay( G_dialogShell ), 100 );
1399      return;
1400   }
1401
1402   /* make args available to callback functions */
1403   G_filop_confirm_fd = filop_confirm_fd;
1404   strcpy(G_directory,destination);
1405   G_fileList    = fileList;
1406   G_nCollisions = nCollisions;
1407   G_mode        = mode;
1408
1409   /* Initialize images for error, warning, ... icons */
1410   if (G_initImages)
1411   {
1412      ImageInitialize(XtDisplay(toplevel));
1413      G_initImages = False;
1414   }
1415
1416   /* Initialize mode-dependent things */
1417   n = 0;
1418   orig_label = actions.actionList[1].label;
1419   orig_msg_num = actions.actionList[1].msg_num;
1420   switch (mode) {
1421      case MOVE_FILE:
1422         title = XtNewString(GETMESSAGE(9, 34, "File Manager - Move Warning"));
1423         XtSetArg (args[n], XmNtitle, title);
1424         n++;
1425         actions.actionList[1].label   =
1426            XtNewString(GETMESSAGE(9, 30, "Cancel Move"));
1427         actions.actionList[1].msg_num = 30;
1428         eMsgOne  = XtNewString(GETMESSAGE(9, 127, "1 object moved."));
1429         eMsgMany = XtNewString(GETMESSAGE(9, 128, "%d objects moved."));
1430         break;
1431      case COPY_FILE:
1432         title = XtNewString(GETMESSAGE(9, 35, "File Manager - Copy Warning"));
1433         XtSetArg (args[n], XmNtitle, title);
1434         n++;
1435         actions.actionList[1].label   =
1436            XtNewString(GETMESSAGE(9, 31, "Cancel Copy"));
1437         actions.actionList[1].msg_num = 31;
1438         eMsgOne  = XtNewString(GETMESSAGE(9, 129, "1 object copied."));
1439         eMsgMany = XtNewString(GETMESSAGE(9, 130, "%d objects copied."));
1440         break;
1441      case LINK_FILE:
1442         title = XtNewString(GETMESSAGE(9, 36, "File Manager - Link Warning"));
1443         XtSetArg (args[n], XmNtitle, title);
1444         n++;
1445         actions.actionList[1].label   =
1446            XtNewString(GETMESSAGE(9, 32, "Cancel Link"));
1447         actions.actionList[1].msg_num = 32;
1448         eMsgOne  = XtNewString(GETMESSAGE(9, 131, "1 object linked."));
1449         eMsgMany = XtNewString(GETMESSAGE(9, 132, "%d objects linked."));
1450         break;
1451      default:
1452         title = XtNewString(GETMESSAGE(9, 33, "File Manager - Move/Copy/Link Warning"));
1453         XtSetArg (args[n], XmNtitle, title);
1454         n++;
1455         eMsgOne  = XtNewString(GETMESSAGE(9, 133, "1 object changed."));
1456         eMsgMany = XtNewString(GETMESSAGE(9, 134, "%d objects changed."));
1457         break;
1458   }
1459
1460
1461   /* Create the dialog shell for the dialog */
1462   G_dialogShell = XmCreateDialogShell (parent_widget, "multicollide dialog", args, n);
1463
1464
1465   /* Create the Manager Widget, form, for the copy dialog */
1466   form  = XtVaCreateWidget ("dialog_form",
1467                              xmFormWidgetClass,  G_dialogShell,
1468                              XmNverticalSpacing,   VERTICAL_SPACING,
1469                              XmNhorizontalSpacing, HORIZONTAL_SPACING,
1470                              XmNdialogStyle,       XmDIALOG_FULL_APPLICATION_MODAL,
1471                              NULL);
1472
1473   /* Create a question dialog icon */
1474   n = 0;
1475   XtSetArg (args[n], XmNbackground, &background); n++;
1476   XtSetArg (args[n], XmNforeground, &foreground); n++;
1477   XtGetValues (form, args, n);
1478
1479   px = XmGetPixmapByDepth(XtScreen(form), "xm_question",
1480                           foreground, background, form->core.depth);
1481   if (px == XmUNSPECIFIED_PIXMAP)
1482     px = XmGetPixmapByDepth(XtScreen(form), "default_xm_question",
1483                      foreground, background, form->core.depth);
1484
1485   icon = XtVaCreateManagedWidget("question_icon",
1486                              xmLabelWidgetClass, form,
1487                              XmNlabelType,        XmPIXMAP,
1488                              XmNlabelPixmap,      px,
1489                              XmNtopAttachment,    XmATTACH_FORM,
1490                              XmNleftAttachment,   XmATTACH_FORM,
1491                              NULL);
1492
1493   /* Create the message label */
1494
1495   nChanged = (nSelected - nCollisions);
1496   if ( nChanged == 0 )
1497     /* This is really stupid but Sun requires it
1498        For now just get it work.
1499      */
1500     s1 = (char *)XtCalloc( 1, 1 );
1501   else if ( nChanged == 1 )
1502   {
1503     s1 = eMsgOne;
1504   }
1505   else
1506   {
1507     s1 = (char *)XtMalloc( 20 + strlen(eMsgMany) );
1508
1509     sprintf(s1, eMsgMany, nChanged);
1510   }
1511
1512   if (nCollisions > 1)
1513   {
1514     int tmp_len = (s1)?strlen(s1):0;
1515     char *tmpmsg,*filemsg=NULL;
1516     int i;
1517
1518     filemsg = XtMalloc(strlen(destination)+3);
1519     sprintf(filemsg,"%s\n",destination);
1520     for(i = 0;i < nCollisions; i++)
1521     {
1522        if(i > 7)
1523        {
1524          char *addmsg;
1525          tmpmsg = GETMESSAGE(27,98, "(Plus %d additional object(s))");
1526          addmsg = XtMalloc(strlen(tmpmsg)+10);
1527          sprintf(addmsg,tmpmsg,nCollisions-8);
1528          filemsg = XtRealloc(filemsg,strlen(filemsg)+strlen(addmsg)+4);
1529          strcat(filemsg,"\n\n");
1530          strcat(filemsg,addmsg);
1531          XtFree(addmsg);
1532          break;
1533        }
1534        filemsg = XtRealloc(filemsg,strlen(filemsg)+strlen(destination)+
1535                       strlen(fileList[i])+3);
1536        strcat(filemsg,"\n");
1537        strcat(filemsg,destination);
1538        strcat(filemsg,"/");
1539        strcat(filemsg,fileList[i]);
1540     }
1541     filemsg = XtRealloc(filemsg,strlen(filemsg)+2);
1542
1543     tmpmsg = GETMESSAGE(9, 70,
1544               "%s\n%d objects have the same name as objects in the folder\n%s");
1545     s = (char *)XtMalloc( tmp_len + strlen(tmpmsg) + strlen(filemsg) + 10);
1546     sprintf(s,tmpmsg,s1, nCollisions, filemsg);
1547     XtFree(filemsg);
1548   }
1549   else
1550   {
1551     int tmp_len = (s1)?strlen(s1):0;
1552     s = (char *)XtMalloc( tmp_len + 10
1553                           + strlen( GETMESSAGE(9, 71, "%s\n1 object has the same name as an object in the folder\n%s") )
1554                           + strlen( destination ) );
1555     sprintf(s, GETMESSAGE(9, 71, "%s\n1 object has the same name as an object in the folder\n%s"), s1, destination);
1556   }
1557
1558   xs = XmStringCreateLocalized(s);
1559   msg_label = XtVaCreateManagedWidget("msg_header",
1560                              xmLabelWidgetClass, form,
1561                              XmNlabelString,      xs,
1562                              XmNalignment,        XmALIGNMENT_BEGINNING,
1563                              XmNtopAttachment,    XmATTACH_FORM,
1564                              XmNleftAttachment,   XmATTACH_WIDGET,
1565                              XmNleftWidget,       icon,
1566                              XmNleftOffset,       HORIZONTAL_SPACING,
1567                              XmNrightAttachment,  XmATTACH_FORM,
1568                              NULL);
1569   XmStringFree(xs);
1570   XtFree(s);
1571   XtFree(s1);
1572   XtFree(eMsgOne);
1573   XtFree(eMsgMany);
1574
1575
1576   /* create the action-question */
1577   xs = XmStringCreateLocalized(GETMESSAGE(9, 20, "What do you want to do?"));
1578   action_label = XtVaCreateManagedWidget("action-question",
1579                              xmLabelWidgetClass, form,
1580                              XmNlabelString,      xs,
1581                              XmNalignment,        XmALIGNMENT_BEGINNING,
1582                              XmNtopAttachment,    XmATTACH_WIDGET,
1583                              XmNtopWidget,        msg_label,
1584                              XmNtopOffset,        3*VERTICAL_SPACING,
1585                              XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET,
1586                              XmNleftWidget,       msg_label,
1587                              XmNleftOffset,       0,
1588                              NULL);
1589   XmStringFree(xs);
1590
1591   /* create radio box */
1592
1593   n = 0;
1594   XtSetArg (args[n], XmNorientation,      XmVERTICAL);               n++;
1595   XtSetArg (args[n], XmNtopAttachment,    XmATTACH_WIDGET);          n++;
1596   XtSetArg (args[n], XmNtopWidget,        action_label);             n++;
1597   XtSetArg (args[n], XmNleftAttachment,   XmATTACH_OPPOSITE_WIDGET); n++;
1598   XtSetArg (args[n], XmNleftWidget,       action_label);             n++;
1599   XtSetArg (args[n], XmNleftOffset,       2*HORIZONTAL_SPACING);     n++;
1600   radio = (Widget) XmCreateRadioBox(form, "radio_box", args, n);
1601
1602   /* create the radio buttons ... default button is replace */
1603   xs = XmStringCreateLocalized(GETMESSAGE(9, 56, "Replace existing objects"));
1604
1605   if(Same)
1606       set = FALSE;
1607   else
1608       set = TRUE;
1609
1610   radioButton1 = XtVaCreateManagedWidget("radio_toggle1",
1611                                          xmToggleButtonWidgetClass, radio,
1612                                          XmNalignment,   XmALIGNMENT_BEGINNING,
1613                                          XmNlabelString, xs,
1614                                          XmNset,         set,
1615                                          NULL);
1616   XmStringFree(xs);
1617   if(Same)
1618   {
1619       XtSetSensitive(radioButton1, False);
1620       set = TRUE;
1621       xs = XmStringCreateLocalized(GETMESSAGE(9, 141, "Rename new objects by appending a number"));
1622   }
1623   else
1624   {
1625       XtSetSensitive(radioButton1, True);
1626       set = FALSE;
1627       xs = XmStringCreateLocalized(GETMESSAGE(9, 57, "Rename existing objects by appending a number"));
1628   }
1629
1630   G_multi_rename_toggle = XtVaCreateManagedWidget("radio_toggle2",
1631                                                   xmToggleButtonWidgetClass, radio,
1632                                                   XmNalignment,   XmALIGNMENT_BEGINNING,
1633                                                   XmNset,         set,
1634                                                   XmNlabelString, xs,
1635                                                   NULL);
1636   XmStringFree(xs);
1637
1638   XtManageChild(radio);
1639
1640
1641   /* create the action area  */
1642   actionArea = Create_Action_Area(form, actions, NULL);
1643   separator  =  XtVaCreateManagedWidget("separator",
1644                                         xmSeparatorWidgetClass, form,
1645                                         XmNtopAttachment,     XmATTACH_WIDGET,
1646                                         XmNtopWidget,         radio,
1647                                         XmNbottomAttachment,  XmATTACH_WIDGET,
1648                                         XmNbottomWidget,      actionArea,
1649                                         XmNleftAttachment,    XmATTACH_FORM,
1650                                         XmNrightAttachment,   XmATTACH_FORM,
1651                                         NULL);
1652
1653
1654   /* set initial keyborad focus to the action button area */
1655   XtVaSetValues(form,
1656                 XmNinitialFocus, actionArea,
1657                 NULL);
1658
1659   /* Manage the dialog */
1660   XtManageChild(form);
1661
1662
1663   XtFree(title);
1664   XtFree(actions.actionList[1].label);
1665   actions.actionList[1].label = orig_label;
1666   actions.actionList[1].msg_num = orig_msg_num;
1667   return;
1668
1669 }  /* end create_multicollide_dialog */
1670
1671
1672
1673 /*--------------------------------------------------------------------
1674  *
1675  * Create Action Area
1676  *
1677  * Use of this function requires #include "sharedFuncs.h"
1678  * The source for Create_Action_Area is in dtfile/OverWrite.c and
1679  * dtfile/dtcopy/utils.c. Because it uses GETMESSAGE, it could not
1680  * be placed in dtcopy/sharedFunc.c.
1681  *
1682  *------------------------------------------------------------------*/
1683
1684 Widget
1685 Create_Action_Area(
1686         Widget parent_widget,
1687         ActionAreaDefn actions,
1688         Widget *pushbutton_array)
1689 {
1690   Widget action_area, widget;
1691   int i;
1692   int fractbase_value;
1693   XmString xm_string;
1694
1695
1696   if (actions.defaultAction < 0  ||  actions.defaultAction > actions.numActions-1)
1697      actions.defaultAction = 0;
1698
1699   fractbase_value = (TIGHTNESS * actions.numActions) - 1;
1700   action_area = XtVaCreateWidget("action_area", xmFormWidgetClass ,parent_widget,
1701                                 XmNfractionBase, fractbase_value,
1702                                 XmNleftAttachment, XmATTACH_FORM,
1703                                 XmNrightAttachment, XmATTACH_FORM,
1704                                 XmNbottomAttachment, XmATTACH_FORM,
1705                                 NULL);
1706
1707   for (i=0; i < actions.numActions ;i++ )
1708     {
1709       xm_string = XmStringCreateLocalized(GETMESSAGE(actions.actionList[i].msg_set,
1710                                                 actions.actionList[i].msg_num,
1711                                                 actions.actionList[i].label));
1712       widget = XtVaCreateManagedWidget(actions.actionList[i].label,
1713                xmPushButtonWidgetClass, action_area,
1714                XmNleftAttachment,     (i ? XmATTACH_POSITION: XmATTACH_FORM),
1715                XmNleftPosition,       (TIGHTNESS * i),
1716                XmNtopAttachment,      XmATTACH_FORM,
1717                XmNbottomAttachment,   XmATTACH_FORM,
1718                XmNrightAttachment,
1719                         ((i != (actions.numActions - 1)) ? XmATTACH_POSITION: XmATTACH_FORM),
1720                XmNrightPosition,      ((TIGHTNESS*i) + (TIGHTNESS - 1)),
1721                XmNshowAsDefault,      (i == actions.defaultAction),
1722                XmNdefaultButtonShadowThickness, 1,
1723                XmNlabelString,         xm_string,
1724                NULL);
1725       XmStringFree(xm_string);
1726
1727
1728
1729        if (actions.actionList[i].callback)
1730          {
1731            XtAddCallback(widget, XmNactivateCallback,
1732                          actions.actionList[i].callback, actions.actionList[i].data);
1733          }
1734
1735        if (i == actions.defaultAction)
1736          {
1737             Dimension height, h;
1738             XtVaGetValues (action_area, XmNmarginHeight, &h, NULL);
1739             XtVaGetValues (widget, XmNheight, &height, NULL);
1740
1741             height +=2 * h;
1742             XtVaSetValues (action_area,
1743                            XmNdefaultButton, widget,
1744                            XmNpaneMaximum,   height,
1745                            XmNpaneMinimum,   height,
1746                            NULL);
1747
1748          }
1749
1750        if (pushbutton_array != NULL)
1751            pushbutton_array[i] = widget;
1752
1753     } /* endfor */
1754
1755    XtManageChild(action_area);
1756    return action_area;
1757
1758 }  /* end Create_Action_Area */
1759
1760
1761
1762 /*--------------------------------------------------------------------
1763  *
1764  * Get Variable Message
1765  *
1766  * Return the appropriate message for the current mode (move, copy,
1767  * link, or other).
1768  *
1769  *------------------------------------------------------------------*/
1770
1771 static char *
1772 getVariableMessage(
1773         VariableMessage message,
1774         int             mode)
1775 {
1776    switch (message)
1777    {
1778       case vm_replaceCannotDeleteFolder:
1779            switch (mode)
1780            {
1781               case MOVE_FILE:
1782                    return GETMESSAGE(9, 95, "Move Canceled - the folder was not moved.\n\n\
1783 The folder you want to replace could not be deleted\n\
1784 because an object inside that folder could not be deleted.\n\
1785 Some other objects inside that folder may have already been\n\
1786 deleted before the move process was halted.\n\n\
1787 The most probable cause of this problem is that you do not\n\
1788 have Write permission for the object that could not be removed.\n\
1789 Change Write permission or manually rename the folder you\n\
1790 are moving so it no longer has the same name.");
1791                    break;
1792               case COPY_FILE:
1793                    return GETMESSAGE(9, 96, "Copy Canceled - the folder was not copied.\n\n\
1794 The folder you want to replace could not be deleted\n\
1795 because an object inside that folder could not be deleted.\n\
1796 Some other objects inside that folder may have already been\n\
1797 deleted before the copy process was halted.\n\n\
1798 The most probable cause of this problem is that you do not\n\
1799 have Write permission for the object that could not be removed.\n\
1800 Change Write permission or manually rename the folder you\n\
1801 are copying so it no longer has the same name.");
1802                    break;
1803               case LINK_FILE:
1804                    return GETMESSAGE(9, 97, "Link Canceled - the folder was not linked.\n\n\
1805 The folder you want to replace could not be deleted\n\
1806 because an object inside that folder could not be deleted.\n\
1807 Some other objects inside that folder may have already been\n\
1808 deleted before the link process was halted.\n\n\
1809 The most probable cause of this problem is that you do not\n\
1810 have Write permission for the object that could not be removed.\n\
1811 Change Write permission or manually rename the folder you\n\
1812 are linking so it no longer has the same name.");
1813                    break;
1814               default:
1815                    return GETMESSAGE(9, 98, "Operation Canceled - the folder was not changed.\n\n\
1816 The folder you want to replace could not be deleted\n\
1817 because an object inside that folder could not be deleted.\n\
1818 Some other objects inside that folder may have already been\n\
1819 deleted before the process was halted.\n\n\
1820 The most probable cause of this problem is that you do not\n\
1821 have Write permission for the object that could not be removed.\n\
1822 Change Write permission or manually rename the folder you\n\
1823 are changing so it no longer has the same name.");
1824                    break;
1825            }  /* end switch (mode) */
1826
1827       case vm_replaceCannotDeleteFile:
1828            switch (mode)
1829            {
1830               case MOVE_FILE:
1831                    return  GETMESSAGE(9, 99, "Move Canceled\n\n\
1832 %s\n\
1833 cannot be removed.\n\n\
1834 The most probable cause of this problem is that\n\
1835 you do not have Write permission for the file.\n\
1836 Change Write permission or manually rename the\n\
1837 file you are moving so it no longer has the same name.");
1838                    break;
1839               case COPY_FILE:
1840                    return  GETMESSAGE(9, 100, "Copy Canceled\n\n\
1841 %s\n\
1842 cannot be removed.\n\n\
1843 The most probable cause of this problem is that\n\
1844 you do not have Write permission for the file.\n\
1845 Change Write permission or manually rename the\n\
1846 file you are copying so it no longer has the same name.");
1847                    break;
1848               case LINK_FILE:
1849                    return  GETMESSAGE(9, 101, "Link Canceled\n\n\
1850 %s\n\
1851 cannot be removed.\n\n\
1852 The most probable cause of this problem is that\n\
1853 you do not have Write permission for the file.\n\
1854 Change Write permission or manually rename the\n\
1855 file you are linking so it no longer has the same name.");
1856                    break;
1857               default:
1858                    return  GETMESSAGE(9, 102, "Operation Canceled\n\n\
1859 %s\n\
1860 cannot be removed.\n\n\
1861 The most probable cause of this problem is that\n\
1862 you do not have Write permission for the file.\n\
1863 Change Write permission or manually rename the\n\
1864 file you are changing so it no longer has the same name.");
1865                    break;
1866            }  /* end switch (mode) */
1867
1868       case vm_multiCannotRenameMany:
1869            switch (mode)
1870            {
1871               case MOVE_FILE:
1872                    return GETMESSAGE(9, 103, "Move Canceled - None of the objects were moved.\n\n\
1873  The following object could not be automatically renamed\n\
1874 %s\n\n\
1875 %d objects were renamed before the move process was halted.\n\n\
1876 The most probable cause of this problem is that you do not have Write\n\
1877 permission for the above object. Change Write permission or manually\n\
1878 rename the object you are moving so it no longer has the same name.");
1879                    break;
1880               case COPY_FILE:
1881                    return GETMESSAGE(9, 104, "Copy Canceled - None of the objects were copied.\n\n\
1882  The following object could not be automatically renamed\n\
1883 %s\n\n\
1884 %d objects were renamed before the copy process was halted.\n\n\
1885 The most probable cause of this problem is that you do not have Write\n\
1886 permission for the above object. Change Write permission or manually\n\
1887 rename the object you are copying so it no longer has the same name.");
1888                    break;
1889               case LINK_FILE:
1890                    return GETMESSAGE(9, 105, "Link Canceled - None of the objects were linked.\n\n\
1891  The following object could not be automatically renamed\n\
1892 %s\n\n\
1893 %d objects were renamed before the link process was halted.\n\n\
1894 The most probable cause of this problem is that you do not have Write\n\
1895 permission for the above object. Change Write permission or manually\n\
1896 rename the object you are linking so it no longer has the same name.");
1897                    break;
1898               default:
1899                    return GETMESSAGE(9, 106, "Operation Canceled - None of the objects were changed.\n\n\
1900  The following object could not be automatically renamed\n\
1901 %s\n\n\
1902 %d objects were renamed before the process was halted.\n\n\
1903 The most probable cause of this problem is that you do not have Write\n\
1904 permission for the above object. Change Write permission or manually\n\
1905 rename the object you are changing so it no longer has the same name.");
1906                    break;
1907            }  /* end switch (mode) */
1908
1909       case vm_multiCannotRenameOne:
1910            switch (mode)
1911            {
1912               case MOVE_FILE:
1913                    return GETMESSAGE(9, 107, "Move Canceled - None of the objects were moved.\n\n\
1914  The following object could not be automatically renamed\n\
1915 %s\n\n\
1916 1 object was renamed before the move process was halted.\n\n\
1917 The most probable cause of this problem is that you do not have Write\n\
1918 permission for the above object. Change Write permission or manually\n\
1919 rename the object you are moving so it no longer has the same name.");
1920                    break;
1921               case COPY_FILE:
1922                    return GETMESSAGE(9, 108, "Copy Canceled - None of the objects were copied.\n\n\
1923  The following object could not be automatically renamed\n\
1924 %s\n\n\
1925 1 object was renamed before the copy process was halted.\n\n\
1926 The most probable cause of this problem is that you do not have Write\n\
1927 permission for the above object. Change Write permission or manually\n\
1928 rename the object you are copying so it no longer has the same name.");
1929                    break;
1930               case LINK_FILE:
1931                    return GETMESSAGE(9, 109, "Link Canceled - None of the objects were linked.\n\n\
1932  The following object could not be automatically renamed\n\
1933 %s\n\n\
1934 1 object was renamed before the link process was halted.\n\n\
1935 The most probable cause of this problem is that you do not have Write\n\
1936 permission for the above object. Change Write permission or manually\n\
1937 rename the object you are linking so it no longer has the same name.");
1938                    break;
1939               default:
1940                    return GETMESSAGE(9, 110, "Operation Canceled - None of the objects were changed.\n\n\
1941  The following object could not be automatically renamed\n\
1942 %s\n\n\
1943 1 object was renamed before the process was halted.\n\n\
1944 The most probable cause of this problem is that you do not have Write\n\
1945 permission for the above object. Change Write permission or manually\n\
1946 rename the object you are changing so it no longer has the same name.");
1947                    break;
1948            }  /* end switch (mode) */
1949
1950       case vm_multiCannotDeleteFolderMany:
1951            switch (mode)
1952            {
1953               case MOVE_FILE:
1954                    return GETMESSAGE(9, 111, "Move Canceled - none of the objects were moved.\n\n\
1955 A folder that you want to replace could not be deleted.\n\
1956    Folder: %s\n\n\
1957 Some objects inside this folder may have been deleted\n\
1958 before the move process was halted.\n\n\
1959 %d other objects have been deleted.\n\n\
1960 The most probable cause of this problem is that you do not have Write\n\
1961 permission for the above folder. Change Write permission or manually\n\
1962 rename the folder you are moving so it no longer has the same name.");
1963                    break;
1964               case COPY_FILE:
1965                    return GETMESSAGE(9, 112, "Copy Canceled - none of the objects were copied.\n\n\
1966 A folder that you want to replace could not be deleted.\n\
1967    Folder: %s\n\n\
1968 Some objects inside this folder may have been deleted\n\
1969 before the copy process was halted.\n\n\
1970 %d other objects have been deleted.\n\n\
1971 The most probable cause of this problem is that you do not have Write\n\
1972 permission for the above folder. Change Write permission or manually\n\
1973 rename the folder you are copying so it no longer has the same name.");
1974                    break;
1975               case LINK_FILE:
1976                    return GETMESSAGE(9, 113, "Link Canceled - none of the objects were linked.\n\n\
1977 A folder that you want to replace could not be deleted.\n\
1978    Folder: %s\n\n\
1979 Some objects inside this folder may have been deleted\n\
1980 before the link process was halted.\n\n\
1981 %d other objects have been deleted.\n\n\
1982 The most probable cause of this problem is that you do not have Write\n\
1983 permission for the above folder. Change Write permission or manually\n\
1984 rename the folder you are linking so it no longer has the same name.");
1985                    break;
1986               default:
1987                    return GETMESSAGE(9, 114, "Operation Canceled - none of the objects were changed.\n\n\
1988 A folder that you want to replace could not be deleted.\n\
1989    Folder: %s\n\n\
1990 Some objects inside this folder may have been deleted\n\
1991 before the process was halted.\n\n\
1992 %d other objects have been deleted.\n\n\
1993 The most probable cause of this problem is that you do not have Write\n\
1994 permission for the above folder. Change Write permission or manually\n\
1995 rename the folder you are changing so it no longer has the same name.");
1996                    break;
1997            }  /* end switch (mode) */
1998
1999       case vm_multiCannotDeleteFolderOne:
2000            switch (mode)
2001            {
2002               case MOVE_FILE:
2003                    return GETMESSAGE(9, 115, "Move Canceled - none of the objects were moved.\n\n\
2004 A folder that you want to replace could not be deleted.\n\
2005    Folder: %s\n\n\
2006 Some objects inside this folder may have been deleted\n\
2007 before the move process was halted.\n\n\
2008 1 other object has been deleted.\n\n\
2009 The most probable cause of this problem is that you do not have Write\n\
2010 permission for the above folder. Change Write permission or manually\n\
2011 rename the folder you are moving so it no longer has the same name.");
2012                    break;
2013               case COPY_FILE:
2014                    return GETMESSAGE(9, 116, "Copy Canceled - none of the objects were copied.\n\n\
2015 A folder that you want to replace could not be deleted.\n\
2016    Folder: %s\n\n\
2017 Some objects inside this folder may have been deleted\n\
2018 before the copy process was halted.\n\n\
2019 1 other object has been deleted.\n\n\
2020 The most probable cause of this problem is that you do not have Write\n\
2021 permission for the above folder. Change Write permission or manually\n\
2022 rename the folder you are copying so it no longer has the same name.");
2023                    break;
2024               case LINK_FILE:
2025                    return GETMESSAGE(9, 117, "Link Canceled - none of the objects were linked.\n\n\
2026 A folder that you want to replace could not be deleted.\n\
2027    Folder: %s\n\n\
2028 Some objects inside this folder may have been deleted\n\
2029 before the link process was halted.\n\n\
2030 1 other object has been deleted.\n\n\
2031 The most probable cause of this problem is that you do not have Write\n\
2032 permission for the above folder. Change Write permission or manually\n\
2033 rename the folder you are linking so it no longer has the same name.");
2034                    break;
2035               default:
2036                    return GETMESSAGE(9, 118, "Operation Canceled - none of the objects were changed.\n\n\
2037 A folder that you want to replace could not be deleted.\n\
2038    Folder: %s\n\n\
2039 Some objects inside this folder may have been deleted\n\
2040 before the process was halted.\n\n\
2041 1 other object has been deleted.\n\n\
2042 The most probable cause of this problem is that you do not have Write\n\
2043 permission for the above folder. Change Write permission or manually\n\
2044 rename the folder you are changing so it no longer has the same name.");
2045                    break;
2046            }  /* end switch (mode) */
2047
2048       case vm_multiCannotDeleteFileMany:
2049            switch (mode)
2050            {
2051               case MOVE_FILE:
2052                    return GETMESSAGE(9, 119, "Move Canceled - none of the objects were moved.\n\n\
2053 A file that you want to replace could not be deleted.\n\
2054     File: %s\n\n\
2055 %d other objects have been deleted.\n\n\
2056 The most probable cause of this problem is that you do not have Write\n\
2057 permission for the above file. Change Write permission or manually\n\
2058 rename the file you are moving so it no longer has the same name.");
2059                    break;
2060               case COPY_FILE:
2061                    return GETMESSAGE(9, 120, "Copy Canceled - none of the objects were copied.\n\n\
2062 A file that you want to replace could not be deleted.\n\
2063     File: %s\n\n\
2064 %d other objects have been deleted.\n\n\
2065 The most probable cause of this problem is that you do not have Write\n\
2066 permission for the above file. Change Write permission or manually\n\
2067 rename the file you are copying so it no longer has the same name.");
2068                    break;
2069               case LINK_FILE:
2070                    return GETMESSAGE(9, 121, "Link Canceled - none of the objects were linked.\n\n\
2071 A file that you want to replace could not be deleted.\n\
2072     File: %s\n\n\
2073 %d other objects have been deleted.\n\n\
2074 The most probable cause of this problem is that you do not have Write\n\
2075 permission for the above file. Change Write permission or manually\n\
2076 rename the file you are linking so it no longer has the same name.");
2077                    break;
2078               default:
2079                    return GETMESSAGE(9, 122, "Operation Canceled - none of the objects were changed.\n\n\
2080 A file that you want to replace could not be deleted.\n\
2081     File: %s\n\n\
2082 %d other objects have been deleted.\n\n\
2083 The most probable cause of this problem is that you do not have Write\n\
2084 permission for the above file. Change Write permission or manually\n\
2085 rename the file you are changing so it no longer has the same name.");
2086                    break;
2087            }  /* end switch (mode) */
2088
2089       case vm_multiCannotDeleteFileOne:
2090            switch (mode)
2091            {
2092               case MOVE_FILE:
2093                    return GETMESSAGE(9, 123, "Move Canceled - none of the objects were moved.\n\n\
2094 A file that you want to replace could not be deleted.\n\
2095     File: %s\n\n\
2096 1 other object has been deleted.\n\n\
2097 The most probable cause of this problem is that you do not have Write\n\
2098 permission for the above file. Change Write permission or manually\n\
2099 rename the file you are moving so it no longer has the same name.");
2100                    break;
2101               case COPY_FILE:
2102                    return GETMESSAGE(9, 124, "Copy Canceled - none of the objects were copied.\n\n\
2103 A file that you want to replace could not be deleted.\n\
2104     File: %s\n\n\
2105 1 other object has been deleted.\n\n\
2106 The most probable cause of this problem is that you do not have Write\n\
2107 permission for the above file. Change Write permission or manually\n\
2108 rename the file you are copying so it no longer has the same name.");
2109                    break;
2110               case LINK_FILE:
2111                    return GETMESSAGE(9, 125, "Link Canceled - none of the objects were linked.\n\n\
2112 A file that you want to replace could not be deleted.\n\
2113     File: %s\n\n\
2114 1 other object has been deleted.\n\n\
2115 The most probable cause of this problem is that you do not have Write\n\
2116 permission for the above file. Change Write permission or manually\n\
2117 rename the file you are linking so it no longer has the same name.");
2118                    break;
2119               default:
2120                    return GETMESSAGE(9, 126, "Operation Canceled - none of the objects were changed.\n\n\
2121 A file that you want to replace could not be deleted.\n\
2122     File: %s\n\n\
2123 1 other object has been deleted.\n\n\
2124 The most probable cause of this problem is that you do not have Write\n\
2125 permission for the above file. Change Write permission or manually\n\
2126 rename the file you are changing so it no longer has the same name.");
2127                    break;
2128            }  /* end switch (mode) */
2129
2130    }  /* end switch (message) */
2131
2132 }  /* end getVariableMessage */
2133
2134 static Boolean
2135 IsReplaceable(
2136    char *name)
2137 {
2138   struct stat s1;
2139
2140   if(lstat(name,&s1) < 0)
2141     return False;
2142   if (S_ISDIR(s1.st_mode))
2143   {
2144     if(!access(name,02|01))
2145       return True;
2146     return False;
2147   }
2148   else
2149   {
2150     if(!access(name,02))
2151       return True;
2152     return False;
2153   }
2154 }