impure functioncopy

Generate a copy of a file or of a directory

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

Files.copy(oldName, newName);
Files.copy(oldName, newName, replace = true);

Description

Function copy(..) copies a file or a directory to a new location. Via the optional argument replace it can be defined whether an already existing file may be replaced by the required copy.

If oldName/newName are directories, then the newName directory may exist. In such a case the content of oldName is copied into directory newName. If replace = false it is required that the existing files in newName are different from the existing files in oldName.

Example

copy("C:/test1/directory1", "C:/test2/directory2");
   -> the content of directory1 is copied into directory2
      if "C:/test2/directory2" does not exist, it is newly
      created. If "replace=true", files in directory2
      may be overwritten by their copy
copy("test1.txt", "test2.txt")
   -> make a copy of file "test1.txt" with the name "test2.txt"
      in the current directory

Inputs

TypeNameDefaultDescription
StringoldNameName of file or directory to be copied
StringnewNameName of copy of the file or of the directory
Booleanreplacefalse= true, if an existing file may be replaced by the required copy

Contents

NameDescription
copyDirectoryprotectedCopy a directory
copyDirectoryContentsprotected