Copfile

Copfile function copies a file.

The function returns a status 0 on success or a negative code.

The function can be executed locally and remotely.

To copy a file, it must exist beforehand. If a file does not exist, the function returns a negative code.

Syntax

RETURN_VALUE=Copfile(SOURCE_PATH, DESTINATION_PATH)
  • RETURN_VALUEis an integer variable that contains the information returned by the call.
  • SOURCE_PATH is a string variable that contains the path for the file you want to copy.
  • DESTINATION_PATH is a string variable that contains the path to where you want to copy the file.

Example

Local Runtime

# Procedure to copy a log file
 Subprog COPY_LOG_FILE(LOGFILE_NAME, ERR_CODE)
  Const Char LOGFILE_NAME()
  Local Char SOURCE_PATH(GDIMFIC)
  Local Char DESTINATION_PATH(GDIMFIC)
  Variable Integer ERR_CODE 
  
  SOURCE_PATH = filpath("tmp","oraspace"+num$(adxuid(2)),"log",nomap)
  DESTINATION_PATH = filpath("TRA","oraspace"+num$(adxuid(2)),"log",nomap)

   #Copy the file
   ERR_CODE = copFile(SOURCE_PATH, DESTINATION_PATH)
   End ERR_CODE

Remote runtime

# Procedure to move a log file
 Subprog MOVE_LOG_FILE(LOGFILE_NAME, ERR_CODE)
  Const Char LOGFILE_NAME()
  Local Char SOURCE_PATH(GDIMFIC) 
  Local Char DESTINATION_PATH(GDIMFIC) 
  Variable Integer ERR_CODE

  MACHINE = adxmac(0)
  SOURCE_PATH = MACHINE+"@"+filepath("tmp","oraspace"+num$(adxuid(2)),"log",nomap)
  DESTINATION_PATH = MACHINE+"@"+filpath("TRA","oraspace"+num$(adxuid(2)),"log",nomap)

  # Move the file
   ERR_CODE = copFile(SOURCE_PATH, DESTINATION_PATH)
   End ERR_CODE

Return values

Value Explanation
0 Operation succeeded.
-20 File does not exist.
-27 Access denied.
-164 [V]CST_AERRPROT Protocol error.

Notes

Copfile tests the SOURCE_PATH internally to check if its execution occurs locally or remotely.

See also

Delfile
Movfile

Renamefile