copyfile
copies a file
Syntax
copyfile(source, destination) copyfile(source, destination, mode) [status, errmsg] = copyfile(...)
Arguments
- source
a character string: a filename or a directory name.
- destination
a character string: a directory name.
- mode
character string: option to modify the way to copy.
"osdefault"
(default) copy the file using default OS functions."preserve"
preserve symbolic links instead of copying the file content."resolve"
copy the file content.- status
double: 1 if the copy operation succeeded, 0 otherwise.
- errmsg
a character string: the error message if any, or an empty string if no error occurred.
Description
copyfile(source,destination)
copies the file or
directory source
(and subdirectories) to the file or
directory destination
.
If source
is a directory, destination
can not be a file.
![]() | copyfile replaces existing files without warning. |
[status, errmsg] = copyfile(source, destination)
copies source
to destination
, returning the status
and a errmsg
.
Whatever the operating system, if the copy succeeds, the status
is 1
and the errmsg
is empty; if the copy fails, the status
is 0 and the
errmsg
is not empty.
Timestamps and symbolic links are preserved when using the "preserve"
option.
![]() | On Windows, symbolic links might require special privilege. |
Examples
copyfile(SCI+"/etc/scilab.start",TMPDIR+"/scilab.start") [status, msg] = copyfile(SCI+"/etc/scilab.start",TMPDIR);
Report an issue | ||
<< file_system | file_system | deletefile >> |