本文整理汇总了PHP中File_Archive::readSource方法的典型用法代码示例。如果您正苦于以下问题:PHP File_Archive::readSource方法的具体用法?PHP File_Archive::readSource怎么用?PHP File_Archive::readSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File_Archive
的用法示例。
在下文中一共展示了File_Archive::readSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeFromSource
/**
* Remove the files that follow a given predicate from the source
* If URL is null, the files will be removed from the source directly
* Else, URL must link to a source from which the files will be removed
*
* @param File_Archive_Predicate $pred The files that follow the predicate
* (for which $pred->isTrue($source) is true) will be erased
* @param File_Archive_Reader $source A reader that contains the files to remove
*/
function removeFromSource(&$pred, &$toConvert, $URL = null)
{
$source =& File_Archive::_convertToReader($toConvert);
if (PEAR::isError($source)) {
return $source;
}
if ($URL === null) {
$result =& $source;
} else {
if (substr($URL, -1) !== '/') {
$URL .= '/';
}
$result = File_Archive::readSource($source, $URL);
}
$writer = $result->makeWriterRemoveFiles($pred);
if (PEAR::isError($writer)) {
return $writer;
}
$writer->close();
}
示例2: _testRemove
function _testRemove($extension)
{
$writer = File_Archive::toArchive("test.{$extension}", File_Archive::toVariable($x));
$writer->newFile('foo.txt');
$writer->writeData('ABCDEF');
$writer->newFile('bla_to_remove.txt');
$writer->writeData('GHIJKL');
$writer->newFile('bar.txt');
$writer->writeData('MNOP');
$writer->close();
File_Archive::removeFromSource(File_Archive::predEreg('_to_remove'), $source = File_Archive::readSource(File_Archive::readMemory($x, "test.{$extension}"), "test.{$extension}/"));
$this->assertEquals("foo.txt\nbar.txt", implode("\n", $source->getFileList()));
}