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