本文整理汇总了PHP中Archive_Tar::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::add方法的具体用法?PHP Archive_Tar::add怎么用?PHP Archive_Tar::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive_Tar
的用法示例。
在下文中一共展示了Archive_Tar::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFiles
/**
* Method to create an archive file
*
* @param string|array $files
* @return void
*/
public function addFiles($files)
{
if (!is_array($files)) {
$files = array($files);
}
foreach ($files as $file) {
// If file is a directory, loop through and add the files.
if (file_exists($file) && is_dir($file)) {
$realpath = realpath($file);
$dir = new Dir($file, true, true);
$dirFiles = $dir->getFiles();
foreach ($dirFiles as $fle) {
if (file_exists($fle) && !is_dir($fle)) {
$fle = $file . DIRECTORY_SEPARATOR . str_replace($realpath . DIRECTORY_SEPARATOR, '', $fle);
$this->archive->add($fle);
}
}
// Else, just add the file.
} else {
if (file_exists($file)) {
$this->archive->add($file);
}
}
}
}
示例2: add
/**
* Add a file to the archive
*
* @param string $file The file to add
*
* @since 1.0.0
*/
public function add($file)
{
$this->tar->add($file);
}
示例3: die
$candidateData = $mriData->getCandidateData($scanTypes);
$mriDataDictionary = $mriData->getDataDictionary($scanTypes);
//add all dictionary names as excel column headings
foreach ($mriDataDictionary as $dicKey => $dicVal) {
//if column not already present
if (!array_key_exists($dicKey, $candidateData[0])) {
$candidateData[0][$dicKey] = NULL;
}
}
writeExcel($Test_name, $candidateData, $dataDir);
// Clean up
// tar and gzip the product
$tarFile = $dumpName . ".tgz";
// produced dump file name and extension
$tar = new Archive_Tar($tarFile, "gz");
$tar->add("./{$dumpName}/") or die("Could not add files!");
// mv (or as php calls it, 'rename') to a web-accessible pickup directory
rename("./{$tarFile}", "{$destinationDir}/{$tarFile}");
//change, if not a subdirectory
// rm left-over junk, from all that excel file generation.
delTree($dataDir);
// Announce completion
echo "{$tarFile} ready in {$destinationDir}\n";
/**
* Takes a 2D array and saves it as a nicely formatted Excel spreadsheet.
* Metadata columns are preserved, multiple worksheets are used, when appropriate and headers are maintained.
*
* @param string $Test_name File name to be used.
* @param unknown_type $instrument_table A 2D array of the data to be presented in Excel format
* @param unknown_type $dataDir The output directory.
*/
示例4: dirname
// Increase script execution time-limit to 15 min for archiving.
if (!ini_get('safe_mode')) {
@set_time_limit(15 * 60);
}
// create Archive_Tar() object
require_once dirname(__FILE__) . '/Tar.php';
// Compress the archive file
if ($archive_gzip) {
log_msg(date("H:i:s") . ": Archiving SQL files in " . $db_backup_fname . ".gz ...\n");
$tar = new Archive_Tar(DB_BACKUP_PATH . "/" . $db_backup_fname . ".gz", "gz");
} else {
log_msg(date("H:i:s") . ": Archiving SQL files in " . $db_backup_fname . " ...\n");
$tar = new Archive_Tar(DB_BACKUP_PATH . "/" . $db_backup_fname);
}
// Build archive
if ($tar->add("days weeks months")) {
log_msg(date("H:i:s") . ": Archiving succesfull.\n");
log_msg($sep);
// Remove the SQL files
if ($archive_del_sql) {
log_msg(date("H:i:s") . ": Removing SQL-files ...\n");
del_sql_files("days");
del_sql_files("weeks");
del_sql_files("months");
chdir(DB_BACKUP_PATH);
if (rmdir($db_name)) {
log_msg(date("H:i:s") . ": Directory \"{$db_name}\" removed.\n");
} else {
log_msg(date("H:i:s") . ": Error removing directory \"{$db_name}\"!\n", 20);
$db_error_count++;
}