function _forena_copy_reports in Forena Reports 7
Same name and namespace in other branches
- 6.2 forena.admin.inc \_forena_copy_reports()
- 6 forena.admin.inc \_forena_copy_reports()
- 7.2 forena.admin.inc \_forena_copy_reports()
- 7.3 forena.module \_forena_copy_reports()
Recursively copy all report files from the source directory to the destination directory
Parameters
string $src_dir Source directory:
1 call to _forena_copy_reports()
- forena_settings_submit in ./
forena.admin.inc - Added submit handler to create directories and clear menu cache
File
- ./
forena.admin.inc, line 36
Code
function _forena_copy_reports($src_dir) {
static $dest_dir = '';
static $i = 0;
if (!$dest_dir) {
$dest_dir = forena_report_path();
}
if (!file_exists($dest_dir)) {
mkdir($dest_dir);
}
$d = dir($src_dir);
while (false !== ($rpt_file = $d
->read())) {
$src_file = $d->path . '/' . $rpt_file;
$dest_file = $dest_dir . '/' . $rpt_file;
if (is_file($src_file)) {
file_put_contents($dest_file, file_get_contents($src_file));
$i++;
}
else {
if (strpos($rpt_file, '.') !== 0) {
// Recurse into sub directory
$src_save = $src_dir;
$dest_save = $dest_dir;
$dest_dir .= '/' . $rpt_file;
$src_dir .= '/' . $rpt_file;
_forena_copy_reports($src_dir);
$src_dir = $src_save;
$dest_dir = $dest_save;
}
}
}
$d
->close();
return $i;
}