disable the unrecognized nls flag
[AROS-Contrib.git] / dopus / Program / main14.c
blobea371547dcb8cd5da1e9a7118cdfe019a4ad9e01
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopus.h"
33 void doassign(rexx)
34 int rexx;
36 int a,blank=0,tot;
37 char buf[FILEBUF_SIZE],buf1[256];
38 struct Directory *dev,*next;
39 BPTR lock;
41 if (status_iconified) return;
43 buf[0]=0;
44 if (checkdevtot(dopus_curwin[data_active_window])) {
45 dev=dopus_curwin[data_active_window]->firstentry;
46 while (dev) {
47 next=dev->next;
48 if ((dev->selected) && (dev->type==ENTRY_DEVICE) &&
49 ((dev->size==DLT_DIRECTORY) || (dev->size==DLT_LATE) || (dev->size==DLT_NONBINDING))) {
50 tot=0;
51 if (!blank) {
52 expand_path(dev->name,buf1);
53 if ((!whatsit(globstring[STR_ENTER_ASSIGN_NAME],256,buf1,(char *)-1))) {
54 myabort();
55 return;
57 if (buf1[0]==0) blank=1;
59 strcpy(buf,dev->name); buf[(strlen(buf)-1)]=0;
60 if (blank) a = AssignLock(buf,NULL);
61 else switch (dev->size)
63 case DLT_DIRECTORY:
64 if ((lock = Lock(buf1, ACCESS_READ)))
66 if (!(a = AssignLock(buf,lock))) UnLock(lock);
68 else a = 0;
69 break;
70 case DLT_LATE:
71 a = AssignLate(buf,buf1);
72 break;
73 case DLT_NONBINDING:
74 a = AssignPath(buf,buf1);
75 break;
77 // a = Assign(buf,blank ? NULL : buf1);
78 if (!a) dostatustext(globstring[STR_CANT_CANCEL_ASSIGN]);
79 else {
80 tot=1;
81 if (blank) removefile(dev,dopus_curwin[data_active_window],data_active_window,TRUE);
82 else unselect(data_active_window,dev);
85 dev=next;
87 if (tot) okay();
88 return;
90 if (str_pathbuffer[data_active_window][0]==0) return;
91 if (!rexx) {
92 if ((!whatsit(globstring[STR_ENTER_DEVICE_NAME],31,buf,NULL))) {
93 myabort();
94 return;
97 else strcpy(buf,rexx_args[0]);
98 for (a=0;a<strlen(buf);a++)
99 if (buf[a]==':' || buf[a]=='/') buf[a]=0;
100 if (!(Assign(buf,str_pathbuffer[data_active_window]))) okay();
101 else dostatustext(globstring[STR_ASSIGN_FAILED]);
104 int checkdest(w)
105 int w;
107 if (!status_iconified && w>-1 && str_pathbuffer[w][0]==0) {
108 dostatustext(globstring[STR_NO_DESTINATION_SELECTED]);
109 simplerequest(globstring[STR_NO_DESTINATION_SELECTED],
110 globstring[STR_CONTINUE],NULL);
111 return(0);
113 return(1);
116 int checksame(src,dst,type)
117 char *src,*dst;
118 int type;
120 BPTR lk1,lk2;
121 int ret;
123 if (!(lk1=Lock(src,ACCESS_READ))) return(LOCK_DIFFERENT);
124 if (!(lk2=Lock(dst,ACCESS_READ))) {
125 UnLock(lk1);
126 return(LOCK_DIFFERENT);
128 ret = SameLock(lk1,lk2);
129 if ((ret == LOCK_SAME) && (type < 2))
131 int a = (type ? STR_CANT_OVERCOPY_FILES : STR_CANT_COPY_DIR_TO_ITSELF);
132 dostatustext(globstring[a]);
133 simplerequest(globstring[a],globstring[STR_CONTINUE],NULL);
135 UnLock(lk1);
136 UnLock(lk2);
137 return(ret);
140 int expand_path(path,buffer)
141 char *path,*buffer;
143 BPTR lock;
144 APTR save;
145 int suc;
147 save=main_proc->pr_WindowPtr;
148 main_proc->pr_WindowPtr=(APTR)-1;
149 buffer[0]=0;
150 if ((lock=Lock(path,ACCESS_READ))) {
151 PathName(lock,buffer,256);
152 UnLock(lock);
153 suc=1;
155 else suc=0;
156 main_proc->pr_WindowPtr=save;
157 return(suc);