home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 22 gnu
/
22-gnu.zip
/
uucopy.zip
/
uucopy.c
next >
Wrap
C/C++ Source or Header
|
1995-02-26
|
1KB
|
57 lines
#include <process.h>
#include <stdio.h>
#include <sys/types.h>
#include <io.h>
int main(int argc, char *argv[])
{
FILE *fp;
char string[1024];
if (argc != 2) {
printf("UUCOPY V0.01\n\nSYNTAX: UUCOPY filename\n");
return 0;
}
if ((fp=fopen(argv[1],"rt")) == NULL) {
fprintf(stderr,"Cannot open input file %s\n",argv[1]);
return 1;
}
while(fscanf(fp,"%[^\n]\n",&string) != EOF) {
switch (string[0]) {
case '#':
printf("Copying and truncating file %s\n",string+1);
if (spawnlp(P_WAIT,"xcopy.exe","xcopy.exe",string+1,NULL) != 0) {
fprintf(stderr,"Unable to copy file %s\n",string+1);
return 1;
}
if (_truncate(string+1,0) != 0) {
fprintf(stderr,"Unable to truncate file %s\n",string+1);
return 1;
}
break;
case '^':
printf("Copying and deleting file %s\n",string+1);
if (spawnlp(P_WAIT,"xcopy.exe","xcopy.exe",string+1,NULL) != 0) {
fprintf(stderr,"Unable to copy file %s\n",string+1);
return 1;
}
if (unlink(string+1) != 0){
fprintf(stderr,"Unable to delete file %s\n",string+1);
return 1;
}
break;
default :
printf("Copying file %s\n",string);
if (spawnlp(P_WAIT,"xcopy.exe","xcopy.exe",string+1,NULL) != 0) {
fprintf(stderr,"Unable to copy file %s\n",string+1);
return 1;
}
}
}
fclose(fp);
if (unlink(argv[1]) != 0){
fprintf(stderr,"Unable to delete file %s\n",argv[1]);
return 1;
}
return 0;
}