本文整理汇总了PHP中Zend_Search_Lucene_Storage_Directory_Filesystem::deleteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Storage_Directory_Filesystem::deleteFile方法的具体用法?PHP Zend_Search_Lucene_Storage_Directory_Filesystem::deleteFile怎么用?PHP Zend_Search_Lucene_Storage_Directory_Filesystem::deleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Storage_Directory_Filesystem
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Storage_Directory_Filesystem::deleteFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFilesystem
public function testFilesystem()
{
$tempPath = dirname(__FILE__) . '/_tempFiles/_files';
if (is_dir($tempPath)) {
// remove files from temporary direcytory
$dir = opendir($tempPath);
while (($file = readdir($dir)) !== false) {
if (!is_dir($tempPath . '/' . $file)) {
@unlink($tempPath . '/' . $file);
}
}
closedir($dir);
}
$directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($tempPath);
$this->assertTrue($directory instanceof Zend_Search_Lucene_Storage_Directory);
$this->assertEquals(count($directory->fileList()), 0);
$fileObject = $directory->createFile('file1');
$this->assertTrue($fileObject instanceof Zend_Search_Lucene_Storage_File);
unset($fileObject);
$this->assertEquals($directory->fileLength('file1'), 0);
$this->assertEquals(count(array_diff($directory->fileList(), array('file1'))), 0);
$directory->deleteFile('file1');
$this->assertEquals(count($directory->fileList()), 0);
$this->assertFalse($directory->fileExists('file2'));
$fileObject = $directory->createFile('file2');
$this->assertEquals($directory->fileLength('file2'), 0);
$fileObject->writeBytes('0123456789');
unset($fileObject);
$this->assertEquals($directory->fileLength('file2'), 10);
$directory->renameFile('file2', 'file3');
$this->assertEquals(count(array_diff($directory->fileList(), array('file3'))), 0);
$modifiedAt1 = $directory->fileModified('file3');
clearstatcache();
$directory->touchFile('file3');
$modifiedAt2 = $directory->fileModified('file3');
sleep(1);
clearstatcache();
$directory->touchFile('file3');
$modifiedAt3 = $directory->fileModified('file3');
$this->assertTrue($modifiedAt2 >= $modifiedAt1);
$this->assertTrue($modifiedAt3 > $modifiedAt2);
$fileObject = $directory->getFileObject('file3');
$this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), '0123456789');
unset($fileObject);
$fileObject = $directory->createFile('file3');
$this->assertEquals($fileObject->readBytes($directory->fileLength('file3')), '');
unset($fileObject);
$directory->deleteFile('file3');
$this->assertEquals(count($directory->fileList()), 0);
$directory->close();
}
示例2: testMerge
public function testMerge()
{
$segmentsDirectory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files/_source');
$outputDirectory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files');
$segmentsList = array('_0', '_1', '_2', '_3', '_4');
$segmentMerger = new Zend_Search_Lucene_Index_SegmentMerger($outputDirectory, 'mergedSegment');
foreach ($segmentsList as $segmentName) {
$segmentMerger->addSource(new Zend_Search_Lucene_Index_SegmentInfo($segmentName, 2, $segmentsDirectory));
}
$mergedSegment = $segmentMerger->merge();
$this->assertTrue($mergedSegment instanceof Zend_Search_Lucene_Index_SegmentInfo);
unset($mergedSegment);
$mergedFile = $outputDirectory->getFileObject('mergedSegment.cfs');
$mergedFileData = $mergedFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs'));
$sampleFile = $outputDirectory->getFileObject('mergedSegment.cfs.sample');
$sampleFileData = $sampleFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs.sample'));
$this->assertEquals($mergedFileData, $sampleFileData);
$outputDirectory->deleteFile('mergedSegment.cfs');
}
示例3: testDelete
public function testDelete()
{
$directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files');
$segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, 0);
$this->assertFalse($segmentInfo->hasDeletions());
$segmentInfo->delete(0);
$this->assertTrue($segmentInfo->hasDeletions());
$delGen = $segmentInfo->getDelGen();
// don't write changes
unset($segmentInfo);
$segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen);
// Changes wasn't written, segment still has no deletions
$this->assertFalse($segmentInfo1->hasDeletions());
$segmentInfo1->delete(0);
$segmentInfo1->writeChanges();
$delGen = $segmentInfo1->getDelGen();
unset($segmentInfo1);
$segmentInfo2 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen);
$this->assertTrue($segmentInfo2->hasDeletions());
unset($segmentInfo2);
$directory->deleteFile('_1_' . base_convert($delGen, 10, 36) . '.del');
$segmentInfo3 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, -1);
$this->assertFalse($segmentInfo3->hasDeletions());
}