home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 3 / CD_Magazyn_EXEC_nr_3.iso / Internet / Strony_WWW / Opus4.x / DOpus414JRsrc.lha / DirectoryOpus4 / Program / main14.c < prev    next >
C/C++ Source or Header  |  2000-03-08  |  4KB  |  142 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  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.
  11.  
  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.
  16.  
  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.
  20.  
  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.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "dopus.h"
  32.  
  33. void doassign(rexx)
  34. int rexx;
  35. {
  36.     int a,blank=0,tot;
  37.     char buf[FILEBUF_SIZE],buf1[256];
  38.     struct Directory *dev,*next;
  39.  
  40.     if (status_iconified) return;
  41.  
  42.     buf[0]=0;
  43.     if (checkdevtot(dopus_curwin[data_active_window])) {
  44.         dev=dopus_curwin[data_active_window]->firstentry;
  45.         while (dev) {
  46.             next=dev->next;
  47.             if (dev->selected && dev->type==ENTRY_DEVICE && dev->size==DLT_DIRECTORY) {
  48.                 tot=0;
  49.                 if (!blank) {
  50.                     expand_path(dev->name,buf1);
  51.                     if ((!whatsit(globstring[STR_ENTER_ASSIGN_NAME],256,buf1,(char *)-1))) {
  52.                         myabort();
  53.                         return;
  54.                     }
  55.                     if (buf1[0]==0) blank=1;
  56.                 }
  57.                 strcpy(buf,dev->name); buf[(strlen(buf)-1)]=0;
  58.                 if (blank) a=Assign(buf,NULL);
  59.                 else a=Assign(buf,buf1);
  60.                 if (a) dostatustext(globstring[STR_CANT_CANCEL_ASSIGN]);
  61.                 else {
  62.                     tot=1;
  63.                     if (blank) removefile(dev,dopus_curwin[data_active_window],data_active_window,TRUE);
  64.                     else unselect(data_active_window,dev);
  65.                 }
  66.             }
  67.             dev=next;
  68.         }
  69.         if (tot) okay();
  70.         return;
  71.     }
  72.     if (str_pathbuffer[data_active_window][0]==0) return;
  73.     if (!rexx) {
  74.         if ((!whatsit(globstring[STR_ENTER_DEVICE_NAME],31,buf,NULL))) {
  75.             myabort();
  76.             return;
  77.         }
  78.     }
  79.     else strcpy(buf,rexx_args[0]);
  80.     for (a=0;a<strlen(buf);a++)
  81.         if (buf[a]==':' || buf[a]=='/') buf[a]=0;
  82.     if (!(Assign(buf,str_pathbuffer[data_active_window]))) okay();
  83.     else dostatustext(globstring[STR_ASSIGN_FAILED]);
  84. }
  85.  
  86. checkdest(w)
  87. int w;
  88. {
  89.     if (!status_iconified && w>-1 && str_pathbuffer[w][0]==0) {
  90.         dostatustext(globstring[STR_NO_DESTINATION_SELECTED]);
  91.         simplerequest(globstring[STR_NO_DESTINATION_SELECTED],
  92.             globstring[STR_CONTINUE],NULL);
  93.         return(0);
  94.     }
  95.     return(1);
  96. }
  97.  
  98. checksame(src,dst,type)
  99. char *src,*dst;
  100. int type;
  101. {
  102.     BPTR lk1,lk2;
  103.     int ret,a;
  104.  
  105.     if (!(lk1=Lock(src,ACCESS_READ))) return(1);
  106.     if (!(lk2=Lock(dst,ACCESS_READ))) {
  107.         UnLock(lk1);
  108.         return(1);
  109.     }
  110.     if ((ret=(CompareLock(lk1,lk2)))==LOCK_SAME) {
  111.         if (type==0) a=STR_CANT_COPY_DIR_TO_ITSELF;
  112.         else a=STR_CANT_OVERCOPY_FILES;
  113.         dostatustext(globstring[a]);
  114.         simplerequest(globstring[a],globstring[STR_CONTINUE],NULL);
  115.         ret=0;
  116.     }
  117.     else ret=1;
  118.     UnLock(lk1);
  119.     UnLock(lk2);
  120.     return(ret);
  121. }
  122.  
  123. expand_path(path,buffer)
  124. char *path,*buffer;
  125. {
  126.     BPTR lock;
  127.     APTR save;
  128.     int suc;
  129.  
  130.     save=main_proc->pr_WindowPtr;
  131.     main_proc->pr_WindowPtr=(APTR)-1;
  132.     buffer[0]=0;
  133.     if (lock=Lock(path,ACCESS_READ)) {
  134.         PathName(lock,buffer,256);
  135.         UnLock(lock);
  136.         suc=1;
  137.     }
  138.     else suc=0;
  139.     main_proc->pr_WindowPtr=save;
  140.     return(suc);
  141. }
  142.