# tasks/system/CopyTask.php

## \CopyTask
jump to top

Package: phing\tasks\system

A phing copy task. Copies a file or directory to a new file or directory. Files are only copied if the source file is newer than the destination file, or when the destination file does not exist. It is possible to explictly overwrite existing files.

Use {@link Project#createTask} to register a new Task.

Parent(s)
  \Task < \ProjectComponent
Children
  \XsltTask
  \MoveTask
Author
  Andreas Aderhold, andi@binarycloud.com
Copyright
  2001,2002 THYRELL. All rights reserved
Version
  $Revision: 985 $ $Date: 2010-11-11 16:58:35 +0100 (Thu, 11 Nov 2010) $

### Properties

`$completeDirMap= 'array()'`
Default value `array()`Details

Type

`string $description= ''`
inherited

description of the taskInherited from: \Task::$description
Details

Type
  string
Inherited_from
  \Task::$description

`$destDir= 'null'`
Default value `null` Details

Type

`$destFile= 'null'`
Default value `null` Details

Type

`$dirCopyMap= 'array()'`
Default value `array()`Details

Type

`$file= 'null'`
Default value `null` Details

Type

`$fileCopyMap= 'array()'`
Default value `array()`Details

Type

`$fileUtils= 'null'`
Default value `null` Details

Type

`$filelists= 'array()'`
Default value `array()`Details

Type

`$filesets= 'array()'`
Default value `array()`Details

Type

`$filterChains= 'array()'`
Default value `array()`Details

Type

`$flatten= 'false'`
Default value `false` Details

Type

`$haltonerror= 'true'`
Default value `true` Details

Type

`$includeEmpty= 'true'`
Default value `true` Details

Type

`\Location $location= ''`
inherited

stored buildfile locationInherited from: \Task::$location
Details

Type
  \Location
Inherited_from
  \Task::$location

`$mapperElement= 'null'`
Default value `null` Details

Type

`$mode= '0755'`
Default value `0755` Details

Type

`$overwrite= 'false'`
Default value `false` Details

Type

`$preserveLMT= 'false'`
Default value `false` Details

Type

`\Project $project= 'null'`
inherited

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

A reference to the current project instanceInherited from: \ProjectComponent::$project
Default value `null` Details

Type
  \Project
Inherited_from
  \ProjectComponent::$project

`\Target $target= ''`
inherited

owning Target objectInherited from: \Task::$target
Details

Type
  \Target
Inherited_from
  \Task::$target

`string $taskName= ''`
inherited

Taskname for loggerInherited from: \Task::$taskName
Details

Type
  string
Inherited_from
  \Task::$taskName

`string $taskType= ''`
inherited

internal taskname (req)Inherited from: \Task::$taskType
Details

Type
  string
Inherited_from
  \Task::$taskType

`$verbosity= 'Project::MSG_VERBOSE'`
Default value `Project::MSG_VERBOSE` Details

Type

`\RuntimeConfigurable $wrapper= ''`
inherited

wrapper of the taskInherited from: \Task::$wrapper
Details

Type
  \RuntimeConfigurable
Inherited_from
  \Task::$wrapper

### Methods

`__construct( ) : object`

Sets up this object internal stuff. i.e. the Fileutils instance

Returns

Type | Description
--- | ---
object | The CopyTask instnace

Details

Access
  public

`_scan( $fromDir, $toDir, $files, $dirs ) : void`

Compares source files to destination files to see if they should be copied.

Parameters

Name | Type | Description
--- | --- | ---
$fromDir |  |
$toDir |  |
$files |  |
$dirs |  |

Details

Access
  private

`buildMap( $fromDir, $toDir, $names, $mapper, $map ) : void`

Builds a map of filenames (from->to) that should be copied

Parameters

Name | Type | Description
--- | --- | ---
$fromDir |  |
$toDir |  |
$names |  |
$mapper |  |
$map |  |

Details

Access
  private

`createFileList( ) : object`

Nested creator, adds a set of files (nested fileset attribute).

Returns

Type | Description
--- | ---
object | The created filelist object

Details

Access
  public

`createFileSet( ) : object`

Nested creator, creates a FileSet for this task

Returns

Type | Description
--- | ---
object | The created fileset object

Details

Access
  public

`createFilterChain( ) : object`

Creates a filterchain

Returns

Type | Description
--- | ---
object | The created filterchain object

Details

Access
  public

`createMapper( ) : object`

Nested creator, creates one Mapper for this task

Returns

Type | Description
--- | ---
object | The created Mapper type object

Throws

Exception | Description
--- | ---
\BuildException |

Details

Access
  public

`doWork( ) : void`

Actually copies the files

Throws

Exception | Description
--- | ---
\BuildException |

Details

Access
  private

`getDescription( ) : string`
inherited

Returns the textual description of the task

Inherited from: \Task::getDescription()
Returns

Type | Description
--- | ---
string | The text description of the task

`getLocation( ) : \Location`
inherited

Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.

Inherited from: \Task::getLocation()
Returns

Type | Description
--- | ---
\Location | The location object describing the position of this task within the buildfile.

`getOwningTarget( ) : \Target`
inherited

Returns the owning target of this task.

Inherited from: \Task::getOwningTarget()
Returns

Type | Description
--- | ---
\Target | The target object that owns this task

`getProject( ) : \Project`
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()
Returns

Type | Description
--- | ---
\Project | Reference to current porject object

`getRegisterSlot( $slotName ) : void`
inherited

Returns a name

Inherited from: \Task::getRegisterSlot()
Parameters

Name | Type | Description
--- | --- | ---
$slotName |  |

`getRuntimeConfigurableWrapper( ) : \RuntimeConfigurable`
inherited

Returns the wrapper object for runtime configuration

Inherited from: \Task::getRuntimeConfigurableWrapper()
Returns

Type | Description
--- | ---
\RuntimeConfigurable | The wrapper object used by this task

`getTaskName( ) : string`
inherited

Returns the name of task, used only for log messages

Inherited from: \Task::getTaskName()
Returns

Type | Description
--- | ---
string | Name of this task

`getTaskType( ) : string`
inherited

Returns the name of the task under which it was invoked, usually the XML tagname

Inherited from: \Task::getTaskType()
Returns

Type | Description
--- | ---
string | The type of this task (XML Tag)

`init( ) : void`
inherited

Called by the parser to let the task initialize properly.

Inherited from: \Task::init()

Should throw a BuildException if something goes wrong with the build

This is abstract here, but may not be overloaded by subclasses.

Throws

Exception | Description
--- | ---
\BuildException |

`log( string $msg, integer $level = Project::MSG_INFO ) : void`
inherited

Provides a project level log event to the task.

Inherited from: \Task::log()

@param string $msg The message to be logged.

Parameters

Name | Type | Description
--- | --- | ---
$msg | string | The message to log
$level | integer | The priority of the message

Details

See
  \BuildEvent
See
  \BuildListener

`logError( $message, $location = NULL ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$message |  |
$location |  |

`main( ) : true`

The main entry point where everything gets in motion.

Should throw a BuildException if someting goes wrong with the build

This is abstract here. Must be overloaded by real tasks.

Returns

Type | Description
--- | ---
true | on success

Throws

Exception | Description
--- | ---
\BuildException |

Details

Access
  public

`maybeConfigure( ) : void`
inherited

Configure this task if it hasn't been done already.

Inherited from: \Task::maybeConfigure()
`perform( ) : void`
inherited

Perfrom this task

Inherited from: \Task::perform()
`setDescription( string $desc ) : void`
inherited

Sets a textual description of the task

Inherited from: \Task::setDescription()
Parameters

Name | Type | Description
--- | --- | ---
$desc | string | The text describing the task

`setFile( \string/object $file ) : void`

Set the file. We have to manually take care of the type that is coming due to limited type support in php in and convert it manually if neccessary.

Parameters

Name | Type | Description
--- | --- | ---
$file | \string/object | The source file. Either a string or an PhingFile object

Details

Access
  public

`setHaltonerror( boolean $haltonerror ) : void`

Set the haltonerror attribute - when true, will make the build fail when errors are detected.

Parameters

Name | Type | Description
--- | --- | ---
$haltonerror | boolean | Flag if the build should be stopped on errors

Details

Access
  public

`setIncludeEmptyDirs( boolean $bool ) : void`

Set the include empty dirs flag. IntrospectionHelper takes care of booleans in set* methods so we can assume that the right value (boolean primitive) is coming in here.

Parameters

Name | Type | Description
--- | --- | ---
$bool | boolean | Flag if empty dirs should be cpoied too

Details

Access
  public

`setLocation( \Location $location ) : void`
inherited

Sets the location within the buildfile this task occurs. Called by the parser to set location information.

Inherited from: \Task::setLocation()
Parameters

Name | Type | Description
--- | --- | ---
$location | \Location | The location object describing the position of this task within the buildfile.

`setMode( integer $mode ) : void`

Sets the mode to create destination directories with (ignored on Windows).

Default mode is 0755.

Parameters

Name | Type | Description
--- | --- | ---
$mode | integer | Octal mode

Details

Access
  public

`setOverwrite( boolean $bool ) : void`

Set the overwrite flag. IntrospectionHelper takes care of booleans in set* methods so we can assume that the right value (boolean primitive) is coming in here.

Parameters

Name | Type | Description
--- | --- | ---
$bool | boolean | Overwrite the destination file(s) if it/they already exist

Details

Access
  public

`setOwningTarget( \Target $target ) : void`
inherited

Sets the owning target this task belongs to.

Inherited from: \Task::setOwningTarget()
Parameters

Name | Type | Description
--- | --- | ---
$target | \Target | Reference to owning target

`setPreserveLastModified( boolean $bool ) : void`

Set the preserve timestamp flag. IntrospectionHelper takes care of booleans in set* methods so we can assume that the right value (boolean primitive) is coming in here.

Parameters

Name | Type | Description
--- | --- | ---
$bool | boolean | Preserve the timestamp on the destination file

Details

Access
  public

`setProject( \Project $project ) : void`
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()
Parameters

Name | Type | Description
--- | --- | ---
$project | \Project | The reference to the current project

`setRuntimeConfigurableWrapper( \RuntimeConfigurable $wrapper ) : void`
inherited

Sets the wrapper object this task should use for runtime configurable elements.

Inherited from: \Task::setRuntimeConfigurableWrapper()
Parameters

Name | Type | Description
--- | --- | ---
$wrapper | \RuntimeConfigurable | The wrapper object this task should use

`setTaskName( $name ) : string`
inherited

Sets the name of this task for log messages

Inherited from: \Task::setTaskName()
Parameters

Name | Type | Description
--- | --- | ---
$name |  |

Returns

Type | Description
--- | ---
string | A string representing the name of this task for log

`setTaskType( string $name ) : void`
inherited

Sets the type of the task. Usually this is the name of the XML tag

Inherited from: \Task::setTaskType()
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The type of this task (XML Tag)

`setTodir( \string/object $dir ) : void`

Set the toDir. We have to manually take care of the type that is coming due to limited type support in php in and convert it manually if neccessary.

Parameters

Name | Type | Description
--- | --- | ---
$dir | \string/object | The directory, either a string or an PhingFile object

Details

Access
  public

`setTofile( \string/object $file ) : void`

Set the toFile. We have to manually take care of the type that is coming due to limited type support in php in and convert it manually if neccessary.

Parameters

Name | Type | Description
--- | --- | ---
$file | \string/object | The dest file. Either a string or an PhingFile object

Details

Access
  public

`setTstamp( $bool ) : void`

Parameters

Name | Type | Description
--- | --- | ---
$bool |  |

Details

See
  \CopyTask::setPreserveLastModified

`setVerbose( boolean $verbosity ) : void`

Used to force listing of all names of copied files.

Parameters

Name | Type | Description
--- | --- | ---
$verbosity | boolean |

`validateAttributes( ) : void`

Validates attributes coming in from XML

Throws

Exception | Description
--- | ---
\BuildException |

Details

Access
  private

Documentation was generated by DocBlox 0.15.1.