本文整理匯總了PHP中Archive::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP Archive::add方法的具體用法?PHP Archive::add怎麽用?PHP Archive::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Archive
的用法示例。
在下文中一共展示了Archive::add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
public function create($paths, $filename = FALSE)
{
$archive = new Archive('tar');
foreach ($paths as $set) {
$archive->add($set[0], $set[1]);
}
$gzfile = bzcompress($archive->create());
if ($filename == FALSE) {
return $gzfile;
}
if (substr($filename, -8) !== '.tar.bz2') {
// Append tar extension
$filename .= '.tar.bz2';
}
// Create the file in binary write mode
$file = fopen($filename, 'wb');
// Lock the file
flock($file, LOCK_EX);
// Write the tar file
$return = fwrite($file, $gzfile);
// Unlock the file
flock($file, LOCK_UN);
// Close the file
fclose($file);
return (bool) $return;
}
示例2: archive
public function archive($build = FALSE)
{
if ($build === 'build') {
// Load archive
$archive = new Archive('zip');
// Download the application/views directory
$archive->add(APPPATH . 'views/', 'app_views/', TRUE);
// Download the built archive
$archive->download('test.zip');
} else {
echo html::anchor(Router::$current_uri . '/build', 'Download views');
}
}
示例3: create
public static function create($save_path, $files)
{
// Since files can be an array or a path...
if (!is_array($files)) {
$files = array($files);
}
$archive = new Archive();
// Loop through files...(or the one directory/file)
foreach ($files as $file) {
if (file_exists($file)) {
$archive->add($file);
}
}
// Save the file
$archive->save($save_path);
// Status
return file_exists($save_path);
}