> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# fileCopy

> ファイルまたはディレクトリを指定された宛先パスにコピーします。オプションで再帰的なコピーやファイルマスクによるフィルタリングが可能です。

指定されたパスにファイルやディレクトリをコピーします。

## 必要なパラメータ

* **source**：コピーするファイル（filename 含む）またはディレクトリのパス。
* **destination**：コピー先となるファイル（filename 含む）またはディレクトリのパス。

## オプションのパラメータ

* **force**：オペレーションがコピー先のパスに見つからないディレクトリを作成するかどうかを制御。`true` および`false` が使用可能です。デフォルト値は`true` です。これは通常、コピー元のディレクトリ構造を宛先にミラーリングする必要がある場合に、**recurse** パラメータと組み合わせて使用されます。
* **mask**：コピーするエントリを選択する際に使われるパターン。デフォルト値は`*` です。（例えば、`*.xml` でマスクするとソース内のすべてのXML ファイルと一致します。）
* **recurse**：ソースから再帰的にファイルおよびディレクトリをコピー。このケースでは、コピー先はディレクトリととらえられます。`false` および`true` が使用可能です。デフォルト値は`false` です。

## アウトプット属性

* **file:source**：ソースファイルまたはディレクトリへのフルパス。
* **file:destination**：コピー先ファイルまたはディレクトリへのフルパス。

## 例

### 単一ファイルをコピー

```xml theme={null}
<!-- Creating the input item with the associated source and destination attributes -->
<arc:set attr="input.source" value="/tmp/foo/helloworld.txt" />
<arc:set attr="input.destination" value="/tmp/bar/helloworld.txt" />

<!-- Calling fileCopy and passing in the input item -->
<arc:call op="fileCopy" in="input" out="result">
  <!-- Optional: Logging information about the copied file to the application log --> 
  <arc:set attr="_log.info" value="The file located at [result.file:source] was copied to [result.file:destination]"/>
</arc:call>
```

### ディレクトリとその中身を再帰的にコピー

このスクリプトを実行すると、`/tmp/foo` にあるディレクトリ構造が`/tmp/bar`にミラーリングされます。.xml ファイルのみがソースから宛先にコピーされます。

```xml theme={null}
<!-- Creating the input item with the associated source and destination attributes -->
<arc:set attr="input.source" value="/tmp/foo" />
<arc:set attr="input.destination" value="/tmp/bar" />

<!-- Adding the optional mask parameter to only copy files in the directory that have the xml file extension --> 
<arc:set attr="input.mask" value="*.xml" />
<!-- Setting the recurse parameter to true to recursively copy any files and directories inside the source location --> 
<arc:set attr="input.recurse" value="true" />
<!-- Setting the force parameter to true so that the operation creates the necessary directories in the destination -->
<arc:set attr="input.force" value="true"/>  

<!-- Calling fileCopy and passing in the input item -->
<arc:call op="fileCopy" in="input" out="result">
  <!-- Optional: Logging information about the copied file to the application log --> 
  <arc:set attr="_log.info" value="The directory [result.file:source] was copied and placed within the following directory: [result.file:destination]"/>
</arc:call>
```
