Jump to content

DosCopy (OS/2 1.x): Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Legacy
This call copies the specified file or subdirectory to the target file or subdirectory. Introduced with OS/2 1.2.
|RepFunc=[[DosCopy]]
|Remarks=
}}
This call copies the specified file or subdirectory to the target file or subdirectory.


==Syntax==
==Syntax==
Line 10: Line 6:
==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.
;OpMode (USHORT) - input: Word-length bit map that defines how the DosCopy function is done.
:15-2 - Reserved and must be set to zero.
:15-2 - Reserved and must be set to zero.
:1
:1
Line 22: Line 18:


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


==Remarks==
==Remarks==
Line 40: Line 35:


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 50: Line 44:
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.
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.  
[[DosQSysInfo]] is called by an application during initialization to determine the maximum path length allowed by OS/2.


==Example Code==
==Bindings==
===C Binding===
===C ===
<PRE>
<PRE>
#define INCL_DOSFILEMGR
#define INCL_DOSFILEMGR
Line 59: Line 53:
USHORT  rc = DosCopy(SourceName, TargetName, OpMode, 0);
USHORT  rc = DosCopy(SourceName, TargetName, OpMode, 0);


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


USHORT           rc;            /* return code */
USHORT rc;            /* return code */
</PRE>
</PRE>


===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosCopy:FAR
EXTRN  DosCopy:FAR
Line 81: Line 75:
</PRE>
</PRE>


==Related Functions==
==Example Code==
*
for copy and replace
<code>
DosCopy("A:\\dir", "C:\\", 1, 0L);
</code>


[[Category:Dos]]
[[Category:Dos16]]

Latest revision as of 01:33, 26 January 2020

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:

  • 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.

Bindings

C

#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

DosCopy("A:\\dir", "C:\\", 1, 0L);