Finalement,
j'ai réussi en copiant la méthode copy() de la version 1.2 et en
l'adaptant dans mon composant Folder.
Voici la function, elle est presque identique :
function copy($options = array())
{
$Folder =& new Folder();
$to = null;
if (is_string($options))
{
$to = $options;
$options = array();
}
$options = array_merge(array('to'=> $to, 'from'=> $Folder->path,
'mode'=> $this->mode, 'skip'=> array()), $options);
$fromDir = $options['from'];
$toDir = $options['to'];
$mode = $options['mode'];
if (!$Folder->cd($fromDir))
{
$this->__errors[] = sprintf(__('%s not found', true),
$fromDir);
return false;
}
if (!is_dir($toDir)) {
$Folder->mkdirr($toDir, $mode);
}
if (!is_writable($toDir))
{
$this->__errors[] = sprintf(__('%s not writable',
true), $toDir);
return false;
}
$exceptions = array_merge(array('.','..','.svn'),
$options['skip']);
if ($handle = @opendir($fromDir))
{
while (false !== ($item = readdir($handle)))
{
if (!in_array($item, $exceptions))
{
$from = $Folder->addPathElement($fromDir, $item);
$to = $Folder->addPathElement($toDir, $item);
if (is_file($from))
{
if (copy($from, $to))
{
chmod($to, intval($mode, 8));
touch($to, filemtime($from));
$this->__messages[] = sprintf(__('%s
copied to %s', true), $from, $to);
} else {
$this->__errors[] = sprintf(__('%s NOT
copied to %s', true), $from, $to);
}
}
if (is_dir($from) && !file_exists($to))
{
if (mkdir($to, intval($mode, 8)))
{
chmod($to, intval($mode, 8));
$this->__messages[] = sprintf(__('%s
created', true), $to);
$options = array_merge($options,
array('to'=> $to, 'from'=> $from));
$this->copy($options);
} else {
$this->__errors[] = sprintf(__('%s not
created', true), $to);
}
}
}
}
closedir($handle);
} else {
return false;
}
if (!empty($this->__errors)) {
return false;
}
return true;
}
Il y a peut-être moyen de l'améliorer, on verra + tard.
En tous cas, cela fonctionne
--~--~---------~--~----~------------~-------~--~----~
Groupe "Cakephp-fr".
Adresse : [email protected]
Pour résilier : [EMAIL PROTECTED]
Pour les options : http://groups.google.com/group/cakephp-fr?hl=fr
-~----------~----~----~----~------~----~------~--~---