protected function doRun()
{
$data = array();
$srcDirectory = new atoum\fs\path($this->srcDirectory);
foreach (new iterators\recursives\atoum\source($this->srcDirectory) as $file) {
$file = new atoum\fs\path($file);
$data[(string) $file->relativizeFrom($srcDirectory)] = file_get_contents($file);
}
$bootstrapFile = new atoum\fs\path($this->bootstrapFile);
$bootstrapFile = $bootstrapFile->relativizeFrom($srcDirectory);
$bootstrap = '<?php $directory = sys_get_temp_dir() . \'/\' . basename(__FILE__);';
$bootstrap .= '$bootstrap = $directory . \'/' . $bootstrapFile . '\';';
$bootstrap .= 'if (is_file($bootstrap) === false || filemtime(__FILE__) > filemtime($bootstrap))';
$bootstrap .= '{';
$bootstrap .= '$data = eval(substr(file_get_contents(__FILE__), __COMPILER_HALT_OFFSET__));';
$bootstrap .= 'foreach ($data as $file => $contents)';
$bootstrap .= '{';
$bootstrap .= '$file = $directory . \'/\' . $file;';
$bootstrap .= '@mkdir(dirname($file), 0777, true);';
$bootstrap .= '@file_put_contents($file, $contents);';
$bootstrap .= '}';
$bootstrap .= '}';
$bootstrap .= 'require $bootstrap;';
$bootstrap .= '__halt_compiler();';
if (file_put_contents($this->destinationFile, $bootstrap . 'return ' . var_export($data, true) . ';') === false) {
throw new exceptions\runtime(sprintf($this->locale->_('Unable to write in file \'%s\''), $this->destinationFile));
}
return $this;
}