DosCopy (OS/2 1.x)

This call copies the specified file or subdirectory to the target file or subdirectory. Introduced with OS/2 1.2.

Syntax
DosCopy (SourceName, TargetName, OpMode, Reserved)

Parameters

 * SourceName (PSZ) - input : Address of the ASCIIZ path name of the source file, subdirectory, or character device. Global file name characters are not allowed.
 * TargetName (PSZ) - input: Address of the ASCIIZ path name of the target file, subdirectory, or character device. Global file name characters are not allowed.
 * OpMode (USHORT) - input: Word-length bit map that defines how the DosCopy function is done.
 * 15-2 - Reserved and must be set to zero.
 * 1
 * 0 = Replace the target file with the source file.
 * 1 = Append the source file to the target file's end of data. This is ignored when copying a directory or if the target file doesn't exist.
 * 0
 * 0 = Do not copy the source file to the target if the file name already exists within the target directory. If a single file is being copied and the target already exists, an error is returned.
 * 1 = Copy the source file to the target even if the file name already exists within the target directory.


 * Reserved (ULONG) - input : Reserved, must be set to zero.

Return Code

 * rc (USHORT) - return:Return code descriptions are:
 * 0 NO_ERROR
 * 2 ERROR_FILE_NOT_FOUND
 * 3 ERROR_PATH_NOT_FOUND
 * 5 ERROR_ACCESS_DENIED
 * 26 ERROR_NOT_DOS_DISK
 * 32 ERROR_SHARING_VIOLATION
 * 36 ERROR_SHARING_BUFFER_EXCEEDED
 * 87 ERROR_INVALID_PARAMETER
 * 108 ERROR_DRIVE_LOCKED
 * 206 ERROR_FILENAME_EXCED_RANGE
 * 267 ERROR_DIRECTORY

Remarks
DosCopy copies all files and subdirectories in the source path to the target path. Global file name characters are not allowed in source or target names. The source and the target may be on different drives.

In the event of an I/O error, DosCopy takes the following actions before it terminates: Read-only files cannot be replaced by a DosCopy request. If OpMode bit flag0 is set to 1 and read-only files exist in the target, an attempt to replace them with files from the source returns an error.
 * If the source name is that of a subdirectory, the file being copied at the time of the error is deleted from the target path.
 * If the source name is that of a file to be replaced, the file is deleted from the target path.
 * If the source name is that of a file to be appended, the target file is resized to its original size.

File attributes are always copied from the source to the target; however extended attributes (EAs) are not copied in every case. DosCopy copies EAs from the source to the target when creating a file or directory or when replacing an existing file on the target. However, it does not copy them when appending an existing file or when copying files to an existing directory on the target.

If a device name is specified as the target, the source name must be a file, not a directory. When the request is issued, OpMode bit flags 0 and 1 are ignored.

DosQSysInfo is called by an application during initialization to determine the maximum path length allowed by OS/2.

C

 * 1) define INCL_DOSFILEMGR

USHORT rc = DosCopy(SourceName, TargetName, OpMode, 0);

PSZ    SourceName;    /* Source path name */ PSZ    TargetName;    /* Target path name */ USHORT OpMode;        /* Operation mode */ ULONG  0;             /* Reserved (must be zero) */

USHORT rc;            /* return code */ 

MASM
 EXTRN DosCopy:FAR INCL_DOSFILEMGR    EQU 1

PUSH@ ASCIIZ  SourceName    ;Source path name string PUSH@ ASCIIZ  TargetName    ;Target path name string PUSH  WORD    OpMode        ;Operation mode PUSH  DWORD   0             ;Reserved (must be zero) CALL  DosCopy

Returns WORD 

Example Code
for copy and replace