function webfm_insert_dir in Web File Manager 5.2
Same name and namespace in other branches
- 5 webfm_file.inc \webfm_insert_dir()
webfm_insert_dir - inserts files into the webfm_file table
Parameters
string $path - path relative to drupal root:
bool $recur - flag to indicate if recursive operation into sub-dirs:
string &$err_arr - ref to error array for client feedback:
Return value
obj - contains error flag and count of successful and failed inserts
1 call to webfm_insert_dir()
- webfm_ajax in ./
webfm.module - Ajax post requests
File
- ./
webfm_file.inc, line 319
Code
function webfm_insert_dir($path, $recur, &$err_arr) {
$result = new stdClass();
$result->cnt = 0;
$result->errcnt = 0;
if ($handle = opendir($path)) {
$bl = array(
'.',
'..',
'.svn',
'.htaccess',
);
while (false !== ($file = readdir($handle))) {
if (!in_array(strtolower($file), $bl)) {
$file_path = $path . '/' . $file;
if (is_file($file_path)) {
// file
if (!webfm_get_fid($file_path)) {
// not in db
if (webfm_insert_file($file_path, $err_arr)) {
$result->cnt++;
}
else {
$result->errcnt++;
}
}
}
else {
if ($recur && is_dir($file_path)) {
$nest_result = webfm_insert_dir($file_path, $recur, $err_arr);
$result->cnt += $nest_result->cnt;
$result->errcnt += $nest_result->errcnt;
}
}
}
}
closedir($handle);
}
else {
$err_arr[] = 'Cannot open dir ' . $path;
}
return $result;
}