home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
dm.lzh
/
multimove.c
< prev
next >
Wrap
Text File
|
1995-04-07
|
3KB
|
125 lines
/* multimove.c function for DISKMASTER.C */
/* copyright (c) 1995 by Bob Devries */
/* email: bdevries@gil.ipswichcity.qld.gov.au */
/* moves multiple files to target directory */
#include "diskmaster.h"
#include <stdio.h>
#include <strings.h>
#include <modes.h>
#include <errno.h>
int
multimove(numfiles)
int numfiles;
{
extern char **nameptr;
extern short *attrptr;
int dpath, confirm, ask;
char *movcmd;
char *olddev, *newdev;
char *olddir, *newdir;
char *malloc();
int ch, success, x;
gotoxy(1,24);
cleol();
printf(" %cMove tagged files to: ",7);
newdir = malloc(256);
success = lineinput(newdir,80);
if((success == FAIL) || (*newdir == '\0')) {
free(newdir);
return(FAIL);
}
gotoxy(1,24);
cleol();
printf(" %cConfirm each move? y/N ",7);
do {
confirm = toupper(getchar());
flush_kbd();
} while ((confirm != 'Y') && (confirm != 'N') && (confirm != '\n'));
if(confirm == '\n') {
confirm = 'N';
}
olddev = malloc(32);
newdev = malloc(32);
olddir = malloc(256);
getcwd(olddir,256);
dpath = open("@",S_IREAD);
_gs_devn(dpath,olddev);
close(dpath);
if(chdir(newdir) == FAIL) {
open_err(newdir,errno);
free(olddev);
free(newdev);
free(olddir);
free(newdir);
commands();
return(FAIL);
}
dpath = open("@",S_IREAD);
_gs_devn(dpath,newdev);
close(dpath);
if(strcmp(olddev,newdev) != 0) {
gotoxy(1,24);
cleol();
printf(" %cCan't move to different device.",7);
sleep(1);
commands();
chdir(olddir);
free(olddev);
free(newdev);
free(olddir);
free(newdir);
return(FAIL);
}
chdir(olddir);
movcmd = malloc(256);
strcpy(movcmd,"move ");
for(x=1;x<=numfiles;x++) {
if((attrptr[x]&TAG) == TAG) {
attrptr[x]&=0xFF;
strcat(movcmd,nameptr[x]);
strcat(movcmd," ");
strcat(movcmd,newdir);
strcat(movcmd," >>>/nil");
if(confirm == 'Y') {
gotoxy(1,24);
cleol();
printf(" %cMove %s to %s? y/N ",7,nameptr[x],newdir);
do {
ask = toupper(getchar());
flush_kbd();
} while ((ask != 'Y') && (ask != 'N') && (ask != '\n'));
if(ask == '\n') {
ask = 'N';
}
if(ask == 'Y') {
gotoxy(1,24);
cleol();
printf(" Moving %s to %s...",nameptr[x],newdir);
system(movcmd);
}
} else {
gotoxy(1,24);
cleol();
printf(" Moving %s to %s...",nameptr[x],newdir);
system(movcmd);
}
}
*(index(movcmd,' ') + 1) = '\0';
}
free(olddev);
free(newdev);
free(olddir);
free(newdir);
free(movcmd);
commands();
return(PASS);
}
/* EOF multimove.c */