DosCopy (OS/2 1.x): Difference between revisions
Created page with "==Description== This call copies the specified file or subdirectory to the target file or subdirectory. ==Syntax== <PRE> DosCopy (SourceName, TargetName, OpMode, Reserv..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
This call copies the specified file or subdirectory to the target file or subdirectory. | This call copies the specified file or subdirectory to the target file or subdirectory. | ||
==Syntax== | ==Syntax== | ||
DosCopy (SourceName, TargetName, OpMode, Reserved) | |||
DosCopy | |||
==Parameters== | ==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. | ;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. | |||
; 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. | |||
; OpMode (USHORT) - input : Word-length bit map that defines how the DosCopy function is done. | :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. | |||
; Reserved (ULONG) - input : Reserved, must be set to zero. | |||
==Return Code== | ==Return Code== | ||
rc (USHORT) - return | rc (USHORT) - return | ||
Return code descriptions are: | Return code descriptions are: | ||
* 0 NO_ERROR | |||
* 0 | * 2 ERROR_FILE_NOT_FOUND | ||
* 2 | * 3 ERROR_PATH_NOT_FOUND | ||
* 3 | * 5 ERROR_ACCESS_DENIED | ||
* 5 | * 26 ERROR_NOT_DOS_DISK | ||
* 26 | * 32 ERROR_SHARING_VIOLATION | ||
* 32 | * 36 ERROR_SHARING_BUFFER_EXCEEDED | ||
* 36 | * 87 ERROR_INVALID_PARAMETER | ||
* 87 | * 108 ERROR_DRIVE_LOCKED | ||
* 108 | * 206 ERROR_FILENAME_EXCED_RANGE | ||
* 206 | * 267 ERROR_DIRECTORY | ||
* 267 | |||
==Remarks== | ==Remarks== | ||
Line 49: | Line 36: | ||
In the event of an I/O error, DosCopy takes the following actions before it terminates: | In the event of an I/O error, DosCopy takes the following actions before it terminates: | ||
* 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 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 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. | ||
* If the source name is that of a file to be appended, the target file is resized to its original size. | |||
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. | 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. | ||
Line 76: | Line 62: | ||
USHORT rc; /* return code */ | USHORT rc; /* return code */ | ||
</PRE> | </PRE> | ||
===MASM Binding=== | ===MASM Binding=== | ||
Line 92: | Line 76: | ||
Returns WORD | Returns WORD | ||
</PRE> | </PRE> | ||
==Related Functions== | ==Related Functions== | ||
* | * | ||
[[Category:Dos]] | |||
[[Category: |
Revision as of 17:58, 27 February 2017
This call copies the specified file or subdirectory to the target file or subdirectory.
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:
- 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.
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.
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.
Example Code
C Binding
#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 Binding
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