本文整理汇总了PHP中stored_file::archive_file方法的典型用法代码示例。如果您正苦于以下问题:PHP stored_file::archive_file方法的具体用法?PHP stored_file::archive_file怎么用?PHP stored_file::archive_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stored_file
的用法示例。
在下文中一共展示了stored_file::archive_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: archive_stored
/**
* Perform archiving file from stored file.
*
* @param zip_archive $ziparch zip archive instance
* @param string $archivepath file path to archive
* @param stored_file $file stored_file object
* @param file_progress $progress Progress indicator callback or null if not required
* @return bool success
*/
private function archive_stored($ziparch, $archivepath, $file, file_progress $progress = null)
{
$result = $file->archive_file($ziparch, $archivepath);
if (!$result) {
return false;
}
if (!$file->is_directory()) {
return true;
}
$baselength = strlen($file->get_filepath());
$fs = get_file_storage();
$files = $fs->get_directory_files($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), true, true);
foreach ($files as $file) {
// Record progress for each file.
if ($progress) {
$progress->progress();
}
$path = $file->get_filepath();
$path = substr($path, $baselength);
$path = $archivepath . '/' . $path;
if (!$file->is_directory()) {
$path = $path . $file->get_filename();
}
// Ignore result here, partial zipping is ok for now.
$file->archive_file($ziparch, $path);
}
return true;
}
示例2: archive_stored
/**
* Perform archiving file from stored file
*
* @param zip_archive $ziparch zip archive instance
* @param string $archivepath file path to archive
* @param stored_file $file stored_file object
*/
private function archive_stored($ziparch, $archivepath, $file)
{
$file->archive_file($ziparch, $archivepath);
if (!$file->is_directory()) {
return;
}
$baselength = strlen($file->get_filepath());
$fs = get_file_storage();
$files = $fs->get_directory_files($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), true, true);
foreach ($files as $file) {
$path = $file->get_filepath();
$path = substr($path, $baselength);
$path = $archivepath . '/' . $path;
if (!$file->is_directory()) {
$path = $path . $file->get_filename();
}
$file->archive_file($ziparch, $path);
}
}