⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comcpy.c

📁 一个dos操作系统DRDOS的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
;    File              : $Workfile: COMCPY.C$
;
;    Description       :
;
;    Original Author   : DIGITAL RESEARCH
;
;    Last Edited By    : $CALDERA$
;
;-----------------------------------------------------------------------;
;    Copyright Work of Caldera, Inc. All Rights Reserved.
;      
;    THIS WORK IS A COPYRIGHT WORK AND CONTAINS CONFIDENTIAL,
;    PROPRIETARY AND TRADE SECRET INFORMATION OF CALDERA, INC.
;    ACCESS TO THIS WORK IS RESTRICTED TO (I) CALDERA, INC. EMPLOYEES
;    WHO HAVE A NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF
;    THEIR ASSIGNMENTS AND (II) ENTITIES OTHER THAN CALDERA, INC. WHO
;    HAVE ACCEPTED THE CALDERA OPENDOS SOURCE LICENSE OR OTHER CALDERA LICENSE
;    AGREEMENTS. EXCEPT UNDER THE EXPRESS TERMS OF THE CALDERA LICENSE
;    AGREEMENT NO PART OF THIS WORK MAY BE USED, PRACTICED, PERFORMED,
;    COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
;    CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,
;    TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF
;    CALDERA, INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT
;    AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND
;    CIVIL LIABILITY.
;-----------------------------------------------------------------------;
;
;    *** Current Edit History ***
;    *** End of Current Edit History ***
;
;    $Log$
;    ENDLOG
*/

/*
	File		COMCPY.C
	Title		Copy module for command.com

Revision History:-
==================

Date       Description
-----------------------------------------------------------------------------
20/05/86   Command.com copy routine
		Based on earlier comcpy.c but heavily modified
 6/06/86   Destination file given the same attributes as source file
		(only applicable to non concatinate cases etc as per 
		timestamping)
        Verify calls added 
24/06/86   Special case of file+,, ('touch') supported
27/06/86   Destination now only opened at last possible moment
		(in copy1 routine), to speed up floppy to floppy copying
03/07/86   ow supports copy bill+fred bill without destroying the
		original contents of bill. Also supports copy ref.lst+*.lst
		
 4 Aug 86  ANSI C compatibilty MSC /W1
 3 Oct 86  Fix bug in REPWILD temp[12] to temp[13] 
21 Nov 86  Fixed bug in DOSIF MS_DATETIME

-------------	DOS Plus 2.1 and 2.1b internal release
		
 8 Dec 86 Rewritten to handle single drive copying better
		added preread and readsrc
11 Dec 86 Number of files copied message moved into message.c 
11 Dec 86 Gastly fix for single floppy drive copy of large file
		as DOS Plus wont allow us to keep the destination file open
		when swapping floppies
		(ABswap and ABloop1 flags added)
12 Dec 86 Finished and thoroughly tested for DOS Plus 2.1d release
		The few minor bugs remaining are documented in dosplus.doc
		Although the code is now very messy it seems to work well!
31 Dec 86 If copying from aux device, set buffer size to 1
16 Feb 87 Changed check for single physical floppy disk drive
		to make more generic
 8 Sep 87 Incorporation of these DOS Plus sources into the Concurrent
 		DOS COMMAND.EXE and COPY.EXE files. The memory management
		has been modified to use an internal static buffer for
		copying. An unused routines have been deleted.
10 Sep 87 Force BufSize to be a multiple of 512 bytes otherwise
		files greater than the buffer size are not copied.
10 Sep 87 Add an extra check to isfile to check for the case "d:"
13 Oct 87 Add the /Z option which will force the data to be masked
		with 0x7F to zero the top bit.
16 Oct 87 /S option copies hidden files as well as system files
16 Oct 87 Copys files with passwords (if source password specified)
          (nb destination does not receive a password unless one is 
          explicitly set)
19 Oct 87 Added /C confirm option
30 Oct 87 isfile() checks for trailing '\' as a special case
05 Nov 87 Moved isdev(fn1) test till after removing flags from fn1
10 Nov 87 If destination is a device, assume ascii when reading source
          and dont send a final ^Z  (unless overridden by user flags)
 5 Apr 88 If Sharing mode open fails on the source file try using
          a compatibilty mode open. For FrameWork SETUP.EXE.
20 May 88 Update the ISFILE routine to use the FPTR routine. Fixs the
          Novell COPY bug.
25 May 88 Close any open batch files for WS2000 install which copies
          over its installation batch file.
27 May 88 Added string undefs.
28 Sep 88 Read data from the source device till the buffer is full or
          a ^Z has been reached. Donot append a ^Z to a file when copying
          from a device unless /A used.
21 Dec 88 Use IOCTL to determine if a handle is attached to a device
          or not.
1 Mar 89  Ignore '[',']','"' 
14 Apr 89 If dest is a device and /b specified (either src or dst) set
          device to binary
6 Jun 89  Do not explicitly set the hidden attribute on password 
          protected files let OS do it for us.
12 Jun 89 Use all of allocated buffer even for Device Reads
14 Jul 89 Move findeof to assembler for speed
4 Aug 89  Used to ignore /b on concat src if dest was device
6-Mar-90  Watcom C v 7.0
22-Mar-90 Copy with control chars cmd string (get_pno terminate bug)
8-May-90  "File not found" error goes to STDOUT, not STDERR.
24-May-90 samefs uses ms_x_expand to check full physical path
5-Jun-90  BODGE copy to dev to be 1 char at a time so we can retry
          correctly (BDOS bug workaround)
11-Jun-90 "COPY file1 file2 ; " hanging cured. I hate get_pno.
27-Nov-90 samefs() no longer uses ms_x_expand(), for PCNFS
          compatibility.
15-Jan-91 "COPY a+b+c d" no longer stops if b does not exist.

DRDOS BUXTON
------------

1-Mar-91  COPY /B FILE DEVICE is now supported.
          Copying to a dev is no longer 1 char at a time, in anticipation
          of a fix in the BDOS.
2-Apr-91  COPY no longer forces time/date/attributes of source onto
          destination.
7-May-91  time/date is now preserved again, attributes are not.

DRDOS PANTHER
-------------

22-Jun-92 Support for Novell Remote copy added.
          See call to novell_copy().
----------------------------------------------------------------------------
*/

#include	"defines.h"

#include	<string.h>

#if defined(MWC) && defined(strlen)
#undef strcmp			/* These are defined as macros in string.h */
#undef strcpy			/* which are expaneded in line under */
#undef strlen			/* Metaware C. These undefs avoid this. */
#endif

#include	<portab.h>
#include	<mserror.h>

#include	"command.h"		/* COMMAND Definitions */
#include	"dos.h" 		/* MSDOS Functions */
#include	"dosif.h"		/* DOS interface definitions	 */
#include	"toupper.h"
#include	"support.h"		/* Support routines		 */
#include	"global.h"


EXTERN VOID batch_close(VOID);		/* BATCH.C		*/

MLOCAL BYTE * skip_switch(BYTE *);
MLOCAL BYTE * get_p1(BYTE *, BYTE *, BYTE *);
MLOCAL BYTE * get_pno(BYTE *, BYTE *);
MLOCAL BOOLEAN isfile(BYTE *);
MLOCAL VOID addwild(BYTE *);
MLOCAL BOOLEAN dopen(BYTE *);
MLOCAL VOID dclose(BYTE *, WORD, WORD);
MLOCAL BOOLEAN preread(BYTE *);
MLOCAL WORD readsrc(VOID);
MLOCAL WORD copy1(BYTE *, BYTE *);
MLOCAL BOOLEAN lseek(BYTE *);
MLOCAL BOOLEAN samefs(BYTE *, BYTE *, WORD);
MLOCAL WORD ABcheck(BYTE *, BYTE *);
MLOCAL VOID prtsrc(BYTE *);
MLOCAL WORD conf_src(BYTE *);
MLOCAL VOID e_check2(WORD);
MLOCAL BOOLEAN touch(BYTE *);
MLOCAL BYTE * get_pswd(BYTE *);


/* define external variables used */


#define	COPY_VERIFY	(global_flg & 1)	/* Set Verify Flag	*/
#define	COPY_SYS	(global_flg & 2)	/* Include SYSTEM Files	*/
#define	COPY_ZERO	(global_flg & 4)	/* Zero the eighth Bit	*/
#define	COPY_CONFIRM	(global_flg & 8)	/* Confirm each file	*/

#define	COPYSRC_ASC	(sflag & 1)		/* Source is ASCII	*/
#define	COPYSRC_BIN	(sflag & 2)		/* Source is Binary	*/

#define	COPYDST_ASC	(dflag & 1)		/* Destination is ASCII	*/
#define	COPYDST_BIN	(dflag & 2)		/* Destination is BINARY*/

#define	MIN_COPYBUF	(10 * (1024/16))	/* Minimum Copy Buffer Size */
#define	MAX_COPYBUF	(50 * (1024/16))	/* Maximum Copy Buffer Size */

/* define static variables for this module */

MLOCAL BYTE	*lp;
MLOCAL UWORD	global_flg;	/* Global Flags	Verify, System & Zero	*/
MLOCAL UWORD	dflag;
MLOCAL BOOLEAN	sascii; 	/* treat current source file as ascii */
MLOCAL BOOLEAN	sbin;
MLOCAL BOOLEAN	concat;
MLOCAL WORD	nfiles; 	/* number of files copied */

MLOCAL WORD	dfh;		/* destination file handle */
MLOCAL BOOLEAN	dstopen;	/* destination open */
MLOCAL WORD	sfh;
MLOCAL ULONG	src_len;
MLOCAL BOOLEAN	srcopen;	/* flag whether src is still open */
MLOCAL BOOLEAN	srcdev; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -