/** * @deprecated deprecated since version 5.0.0 */ function nc_delete_all_file_and_folder($directory) { $files = nc_double_array_shift(scandir($directory)); $directory = nc_standardize_path_to_folder($directory); foreach ($files as $file) { $full_path = $directory . $file; if (!file_exists($full_path)) { continue; } if (is_dir($full_path)) { nc_delete_all_file_and_folder($full_path); } else { unlink($full_path); } } if (is_dir($directory)) { rmdir($directory); } }
/** * @param string $path * @return bool */ public function delete_template_file_and_folder($path = '') { // path $path = $path ? $path : $this->absolute_path; // check path if (!is_dir($path)) { return false; } // error when trying to delete template folder if (nc_standardize_path_to_folder($this->path_to_root_folder) == $path) { // warning message nc_print_status(sprintf(NETCAT_TEMPLATE_DIR_DELETE_ERROR, $path), 'error'); return false; } // variables $files = nc_double_array_shift(scandir($path)); $directory = nc_standardize_path_to_folder($path); foreach ($files as $file) { $full_path = $directory . $file; // check file existance if (!file_exists($full_path)) { continue; } // file / dir if (is_dir($full_path)) { $this->delete_template_file_and_folder($full_path); } else { // delete file unlink($full_path); } } // delete dir if (is_dir($directory)) { rmdir($directory); } return true; }