Copies a file or directory. Directories are copied recursively. Existing files are overwritten.
l = cp(src, dest, ignoreErrors)
Where:
src
: Name of the file or folder to copy.dest
: Name of the destination ignoreErrors
: False to print a detailed description of the error message.
Optional parameter. Default is False.It returns True if the process has been succesful or False in case of error.
The following program copies file1 to file2:
PROGRAM cpExample
USE FU_Files, ONLY: cp
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path1, path2
path1='file1'
path2='file2'
IF (cp(path1, path2)) THEN
WRITE(*,*) 'Success'
ELSE
WRITE(*,*) 'Error'
END IF
END PROGRAM cpExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | src |
Name of the file to be copied. |
||
character(len=*), | intent(in) | :: | dest |
Name of the destination file. |
||
logical, | intent(in), | optional | :: | ignoreErrors |
False to print a detailed description of the error message. Optional parameter. Default is False. |
True if the process has been succesful. False in case of error.