FSCopyStatement ::= |
copy Expr ( except Expr | in Expr | strip Expr | under Expr | ( to | into ) Expr | recursive | echo | Echo | noHidden | keepDirs | compress | store | transform ( Expr | IDENTIFIER )* |
Used by: |
This command copies or processes specific files between file systems and/or archives like JAR, WAR, EAR, ZIP, TAR and Gzipped TAR files.
The first parameter is a string for one or more patterns separated by commas. These patterns should be good for absolute path matches. You can specify an except pattern list to exclude certain files or directories. The source location of the files can be specified by the in clause; the source can be a directory or an archive file. If recursive is specified, files under that source are recursively copied. The destination is specified with to clause if it is a directory, or with into if it is an archive. An archive is either a file name that ends with ".jar", ".zip", ".war", ".ear", ".tar" or ".tar.gz", or an open JarArchive or TarArchive.
When copying files to a directory, the destination is checked for the existance of the files. If a file exists and has the same size and timestamp, by default the file is left uncopied. To override this behavior, you would have to delete that file first, or the whole directory if it is ok. The echo will report to the system output for any files actually copied. The Echo will report any files being copied, no matter whether they are actually copied physically.
The compress and store decorators are only for archiving into a ZIP or JAR file. The under clause allows the files to be stored under a specific folder in an archive; when coping files from an archive, can use strip to strip the leading folder names.
The same command can be used to transform files by the transform clause; this is applicable only to local file system destinations. The transform is a lambda function taking 2 parameters of a source and a destination. The source is an input stream and has these read-only attributes:
name
time
size
isFile
: boolean
fromZip
: boolean
getName()
setName(aName)
setTime(time)
copy(input_stream)
: returns the count
copy()
method simply copies all the bytes from the input stream. If no content is written,
the destination file is not created. This allows sophisticated file filtering.
For text files, it is common to call the toTextInput()
and
toTextOut()
methods of for the source and/or destination.