$source = Mage::getBaseDir();
$dest = Mage::getStoreConfig('Setupstaging_options/product_page/stagingfolder');
mkdir($dest, 0755);
foreach (
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST) as $item) {
if ($item->isDir()) {
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
} else {
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
答案 0 :(得分:1)
如果您有要跳过的文件夹的名称:
$exclude_dirs = array("onedir", "twodir"); // List of directory names to exclude
$source = Mage::getBaseDir();
$dest = Mage::getStoreConfig('Setupstaging_options/product_page/stagingfolder');
mkdir($dest, 0755);
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) {
if ($item->isDir() && !in_array($item->getFilename(), $exclude_dirs)) { // If this Dir's name is not in $exclude_dirs
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
else {
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
}
答案 1 :(得分:0)
我认为你可以使用这个条件:
if ($item->isDir()) {
if($item->getSubPathName() =! "your path directory to exclude"){
mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}
} else {
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
}