当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFileObject::rewind方法代码示例

本文整理汇总了PHP中SplFileObject::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFileObject::rewind方法的具体用法?PHP SplFileObject::rewind怎么用?PHP SplFileObject::rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplFileObject的用法示例。


在下文中一共展示了SplFileObject::rewind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSolution

 /**
  * @return string
  */
 public function getSolution()
 {
     $txt = 'Solution - ' . $this->getName() . ' :' . PHP_EOL;
     foreach (array(1, 2) as $part) {
         try {
             $txt .= '- Part ' . $part . ' : ' . $this->getAnswer($part) . PHP_EOL;
             $this->instructionsFile->rewind();
         } catch (Exception $exception) {
             $txt .= 'Exception while executing part ' . $part . ' : ' . $exception->getMessage() . PHP_EOL;
         }
     }
     return $txt;
 }
开发者ID:FlorianBaba,项目名称:AdventOfCodeSolution,代码行数:16,代码来源:AbstractScriptDay.php

示例2: rewind

 /**
  * Rewind the file pointer
  *
  * If a header row has been set, the pointer is set just below the header
  * row. That way, when you iterate over the rows, that header row is
  * skipped.
  */
 public function rewind()
 {
     $this->file->rewind();
     if (null !== $this->headerRowNumber) {
         $this->file->seek($this->headerRowNumber + 1);
     }
 }
开发者ID:megamanhxh,项目名称:data-import,代码行数:14,代码来源:CsvReader.php

示例3: rewind

 /**
  * Implements Iterator::rewind().
  */
 public function rewind()
 {
     parent::rewind();
     if ($this->startPosition) {
         $this->fseek($this->startPosition);
     }
     $this->linesRead = 0;
 }
开发者ID:WaTech,项目名称:drupal-docker-common,代码行数:11,代码来源:FeedsExLineIterator.php

示例4: finalizeFile

 public function finalizeFile(\SplFileObject $fileObject)
 {
     if ($this->headers !== null) {
         // Create tmp file with header
         $fd = fopen('php://temp', 'w+b');
         fputcsv($fd, $this->headers);
         // Copy file content into tmp file
         $fileObject->rewind();
         fwrite($fd, $fileObject->fread($fileObject->getSize()));
         // Overwrite file content with tmp content
         rewind($fd);
         $fileObject->rewind();
         $fileObject->fwrite(stream_get_contents($fd));
         clearstatcache(true, $fileObject->getPathname());
         fclose($fd);
     }
     // Remove last line feed
     $fileObject->ftruncate($fileObject->getSize() - 1);
 }
开发者ID:ThomasArnaud,项目名称:thelia,代码行数:19,代码来源:CSVSerializer.php

示例5: testFromAppendixA

 /**
  * Test the words found in Appendix A from Mr.
  * Ntais's thesis.
  *
  * The words are not tested against the stem reported in the appendix
  * but against the results of Mr. Ntais's canonical implementation in js
  * found here http://people.dsv.su.se/~hercules/greek_stemmer.gr.html
  */
 public function testFromAppendixA()
 {
     $words = new \SplFileObject(TEST_DATA_DIR . '/Stemmers/GreekStemmerTest/appendix-a-words');
     $stems = new \SplFileObject(TEST_DATA_DIR . '/Stemmers/GreekStemmerTest/appendix-a-stems');
     $words->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
     $stems->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
     $stems->rewind();
     $stemmer = new GreekStemmer();
     $this->checkStemmer($stemmer, $words, $stems);
 }
开发者ID:imonroe,项目名称:coldreader,代码行数:18,代码来源:GreekStemmerTest.php

示例6: rewind

 public function rewind()
 {
     parent::rewind();
     // If we are getting the first line as columns, take them then skip to
     // the next line.
     if ($this->_firstLineIsColumns) {
         $this->setColumns(parent::current());
         parent::next();
     }
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:10,代码来源:CSVFile.php

示例7: freeUsedRequestCount

 /**
  * Free the used slots
  *
  * @param $sliced_report_definitions_count
  */
 private function freeUsedRequestCount($sliced_report_definitions_count)
 {
     $this->file_counter->flock(LOCK_EX);
     $this->file_counter->rewind();
     $used_request_count = (int) $this->file_counter->fgets();
     $new_used_request_count = $used_request_count - $sliced_report_definitions_count;
     $this->file_counter->ftruncate(0);
     $this->file_counter->fwrite($new_used_request_count);
     $this->file_counter->flock(LOCK_UN);
 }
开发者ID:ebussola,项目名称:adwords-reports,代码行数:15,代码来源:Reports.php

示例8: testStemmer

 /**
  * Load a set of words and their stems and check if the stemmer
  * produces the correct stems
  *
  * @group Slow
  */
 public function testStemmer()
 {
     $words = new \SplFileObject(TEST_DATA_DIR . '/Stemmers/PorterStemmerTest/words.txt');
     $stems = new \SplFileObject(TEST_DATA_DIR . '/Stemmers/PorterStemmerTest/stems.txt');
     $words->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
     $stems->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::SKIP_EMPTY);
     $stems->rewind();
     $stemmer = new PorterStemmer();
     $this->checkStemmer($stemmer, $words, $stems);
 }
开发者ID:imonroe,项目名称:coldreader,代码行数:16,代码来源:PorterStemmerTest.php

示例9: getWritableFile

 /**
  * Get writable copy of the file
  * 
  * @return SplFileObject
  */
 protected function getWritableFile()
 {
     if ($this->tmpfile === null) {
         $this->tmpfile = new \SplTempFileObject(131072);
         $this->file->rewind();
         foreach ($this->file as $line) {
             $this->tmpfile->fwrite($line);
         }
     }
     return $this->tmpfile;
 }
开发者ID:rejsmont,项目名称:BioSymfony,代码行数:16,代码来源:BioFormatFile.php

示例10: goBeforeCharacter

 /**
  * {@inheritdoc}
  */
 public function goBeforeCharacter(\SplFileObject $file, $characterNumber)
 {
     $file->rewind();
     if ($characterNumber < 0 || $characterNumber > $file->getSize()) {
         throw new OutOfBoundsException();
     }
     for ($i = 0; $i <= $characterNumber - 1; $i++) {
         $file->fgetc();
     }
     return $file;
 }
开发者ID:Babacooll,项目名称:TextFile,代码行数:14,代码来源:SimpleWalker.php

示例11: rewind

 /**
  *  Rewind the \Iterator to the first element
  */
 public function rewind()
 {
     $this->_filepos = null;
     $this->_key = 0;
     if (null === $this->_file) {
         $this->_openFile();
     } elseif ($this->_file) {
         $this->_file->rewind();
         $this->_file->current();
         // Reading first line is necessary for correct loading of file.
         $this->next();
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:16,代码来源:FileIteratorAbstract.php

示例12: getContent

 /**
  *
  * because \SplFileObject::fread() is not available before 5.5.11 anyway
  * 
  * returns the full content of a file, rewinds pointer in the beginning and leaves it at the end
  * but dont rely on this pointer behaviour
  * 
  * @param \SplFileObject $fileObject
  *
  * @return \SplString|string
  */
 public static function getContent(\SplFileObject $fileObject)
 {
     if (class_exists('SplString')) {
         $result = new \SplString();
     } else {
         $result = '';
     }
     $fileObject->rewind();
     while (!$fileObject->eof()) {
         $result .= $fileObject->fgets();
     }
     return $result;
 }
开发者ID:cotya,项目名称:composer-test-framework,代码行数:24,代码来源:FileObject.php

示例13: save

 /**
  * Saves the current upload stream to designated target.
  *
  * @param {string} Target path to save the contents, cannot be a directory.
  * @param {?bool} True to append to target file, defaults to replace.
  * @return {boolean} True on success, false otherwise.
  */
 public function save($path, $append = false)
 {
     if (is_dir($path)) {
         $path = preg_replace('/\\' . preg_quote(DS) . '?$/', '$1/' . $this->getFilename(), $path);
     }
     $target = new \SplFileObject($path, $append ? 'a' : 'w');
     $this->rewind();
     while (!$this->eof()) {
         $target->fwrite($this->fread(4096));
     }
     $target->fflush();
     $target->rewind();
     return $target;
 }
开发者ID:Victopia,项目名称:prefw,代码行数:21,代码来源:RequestPutFile.php

示例14: testAgainstOriginalSedImplementation

 public function testAgainstOriginalSedImplementation()
 {
     $tokenizer = new PennTreeBankTokenizer();
     $tokenized = new \SplFileObject(TEST_DATA_DIR . "/Tokenizers/PennTreeBankTokenizerTest/tokenized");
     $tokenized->setFlags(\SplFileObject::DROP_NEW_LINE);
     $sentences = new \SplFileObject(TEST_DATA_DIR . "/Tokenizers/PennTreeBankTokenizerTest/test.txt");
     $sentences->setFlags(\SplFileObject::DROP_NEW_LINE);
     $tokenized->rewind();
     foreach ($sentences as $sentence) {
         if ($sentence) {
             $this->assertEquals($tokenized->current(), implode(" ", $tokenizer->tokenize($sentence)), "Sentence: '{$sentence}' was not tokenized correctly");
         }
         $tokenized->next();
     }
 }
开发者ID:WHATNEXTLIMITED,项目名称:php-text-analysis,代码行数:15,代码来源:PennTreeBankTokenizerTest.php

示例15: getRaw

 /**
  * Get raw image data from the SplFileObject.
  *
  * @return string
  *         String representation of the raw image binary data
  */
 public function getRaw()
 {
     if (!is_null($this->raw)) {
         return $this->raw;
     }
     // Save our current position
     $position = $this->object->ftell();
     $this->object->rewind();
     $raw = '';
     while ($this->object->valid()) {
         $raw .= $this->object->fgets();
     }
     // Go back to our original position
     $this->object->fseek($position);
     return $this->raw = $raw;
 }
开发者ID:fuzz-productions,项目名称:image-resizer,代码行数:22,代码来源:File.php


注:本文中的SplFileObject::rewind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。