📄 comcpy.c
字号:
MLOCAL BOOLEAN dstdev;
MLOCAL BOOLEAN fullbuf; /* buffer contains data */
MLOCAL BOOLEAN dfailed;
MLOCAL BOOLEAN ABswap; /* single floppy disk drive copy with disk swap */
MLOCAL BOOLEAN tstamp; /* set destination timestamp to same as source */
MLOCAL UWORD date,time; /* source date and time */
MLOCAL UWORD attrib; /* source file attributes */
MLOCAL UWORD amount; /* amount of real data in buffer */
/* ---- start of code ---------------------------------------------*/
GLOBAL VOID CDECL cmd_copy(cmd)
BYTE *cmd;
{
WORD rmode = 0x0000; /* read mode - normal files only */
BYTE delim;
BYTE npara;
BYTE src[MAX_FILELEN]; /* buffer in which to expand wild source filespec */
BYTE dest[MAX_FILELEN]; /* buffer in which to expand wild destination filespec */
#if defined(PASSWORD)
BYTE password[10]; /* keep note of src password */
#endif
BYTE *olp, *tp;
BYTE *last_delim;
WORD ret;
BOOLEAN scheme1;
BOOLEAN init = YES; /* do initialisations during 1st loop */
BOOLEAN pflag;
BOOLEAN tflag; /* touch flag (special case) */
BOOLEAN confirmed;
UWORD dosvf; /* used to save current dos verify state */
UWORD sflag; /* Source File Options */
/* scheme2 extra bits */
BYTE wdfn[13]; /* used by scheme2 to save wild destination filename */
BYTE *dfptr;
BYTE *ocmd;
BYTE src2[MAX_FILELEN]; /* 2nd src buffer for scheme2 */
DTA search; /* DOS Search Buffer */
sascii = NO; /* indicates if current source is ascii or not */
sbin = NO; /* sbin indicates if an explicit /b found */
concat = NO;
dfailed = ABswap = NO;
srcopen = dstopen = NO; /* No file are Open */
nfiles=0; /* number of files copied */
cmd = deblank(cmd); /* remove leading spaces */
strlwr(cmd); /* force it all to lower case first */
strcpy(heap(),cmd); /* make temp copy of cmd line */
if(f_check(heap(), "vszcab", &global_flg, NO)) /* check for any bad flags */
return; /* exit if any (with message) */
/* also zaps any valid flags but not important is this is a temp copy */
f_check(cmd,"vszc",&global_flg,YES); /* check for, and zap verify, sys, zero and confirm flags */
if(COPY_SYS) {
rmode |= ATTR_SYS; /* read system files also*/
rmode |= ATTR_HID; /* read hidden files also*/
} /* nb /s flag acts globally */
cmd = deblank (cmd); /* deblank incase /v was at start of line */
while(*cmd == *switchar) { /* process any initial switches */
if(*(cmd+1)=='a')
sascii=YES;
if(*(cmd+1)=='b') {
sascii=NO;
sbin=YES;
}
cmd = deblank (cmd+2);
}
lp = get_pno(cmd,&npara);
olp =lp; /* save lp ptr (as lp possibly modified later) */
/* olp is used as the end of the list of source parameters */
if(npara > 1) /* dont remove switches if npara=1 as they will be processed when fn1 switches are checked */
f_check( lp, "ab", &dflag, YES); /* check for, and zap destination a and b flags */
/* store them in dflag for later use */
last_delim = lp-1;
while (*last_delim == 32) last_delim--;
zap_spaces(lp);
cmd = get_p1(src, deblank(cmd), &delim); /* separate 1st filename spec from rest */
if(delim == '=') { /* if the user spells PIP as COPY */
syntax(); /* exit with syntax error */
return;
}
if(npara>2 && delim!='+') {
printf(MSG_INOP); /* invalid number of parameters */
return;
}
if(!d_check(src))
return; /* invalid drive */
f_check( src, "ab", &sflag, YES); /* check for, and zap flags in fn1 */
if(COPYSRC_ASC)
sascii=YES;
if(COPYSRC_BIN) {
sascii=NO; /* nb /b checked last by default */
sbin=YES;
}
zap_spaces (src);
/* do adjustments for special cases */
if (COPYDST_BIN) {
sbin = YES; /* Does it make sense to have source ascii */
sascii = NO; /* and dest binary? I think not. */
}
if(lp[strlen(lp)-1] == ',')
lp[strlen(lp)-1] = '\0'; /* remove comma from end of lp */
if(npara==1 && delim!='+')
if(isfile(lp)) { /* strip drive and path from lp */
lp = fptr(lp); /* ie path\file becomes \path\file */
} /* to file but not if \path\file+ */
else
lp=lp+strlen(lp); /* if dir, lp=\0 */
if(npara==1 && delim=='+') {
delim=' '; /* not concat if 1 parameter */
tp=lp;
while (*tp) { /* remove the + sign from end of lp filespec */
if(*tp == '+')
*tp = ' ';
tp++;
}
}
if(npara>=2 && delim=='+' && *last_delim=='+') {
/* copy fred+bill dest is fred */
lp = fptr(src); /* copy path\fred+bill dest is fred */
olp=cmd+strlen(cmd); /* fiddle olp to end of list of source parameters */
}
if(npara==2 && iswild(src) && /* handle special case */
isfile(lp) && !iswild(lp)) /* of copy *.lst file */
concat = YES; /* (implied concatination) */
tflag = (npara>=3 && delim=='+' && *cmd==','); /* touch special case so set tflag */
if(delim == '+')
concat = YES;
if(concat && !sbin) /* concat is ascii unless a /b switch has occured */
sascii = YES;
dstdev = NO;
if (!iswild(lp) && *lp)
{
get_filename(dest,lp,YES); /* this turns lpt1: into lpt1 */
ret = ms_x_open(dest, OPEN_READ); /* Check if destination is */
if (ret >= 0) /* a device. If so, if /b */
{ /* on src OR dst, copy is */
if (isdev(ret)) /* binary */
{
dstdev = YES;
if (COPYSRC_BIN || (COPYDST_BIN && !concat) || sbin)
{
sbin = YES;
sascii = NO;
} /* If no /b, default to */
else /* ascii */
{
sbin = NO;
sascii = YES;
}
}
ms_x_close (ret);
}
}
mem_alloc(&bufaddr, &bufsize, MIN_COPYBUF, MAX_COPYBUF);
bufsize <<= 4; /* Allocate the Buffer */
bufsize &= ~511; /* Force the buffer size to be a*/
/* multiple of 512 Bytes */
if(bufsize == 0) { /* If the memory allocation */
e_check(ED_MEMORY); /* print a memory error and */
return; /* return to the caller. */
}
#if 0 /* UNBODGE */
/** BODGE **/
if(dstdev) /* copy to dev 1 char at a time */
bufsize = 1; /* so retry operates correctly */
/** BODGE **/
#endif /* UNBODGE */
if(batchflg) /* close the BATCH file if OPEN cos */
batch_close(); /* installation routines copy over */
/* the current batch file. */
dosvf = ms_f_getverify(); /* read present dos verify flag*/
if(COPY_VERIFY)
ms_f_verify(1); /* set verify */
if (lp == get_filename(dest, lp, YES)) {
if (strlen(lp)) {
printf(MSG_SYNTAX); /* bad filename specified */
return;
}
}
#if TRUE
/* ##jc##
* This Code is a Special for IBM Display Write 4 which attempts
* to copy "A:DEFAULT.P*T
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -