本文整理匯總了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);
}
}