Esempio n. 1
0
 /**
  * Copy the resource to a file
  *
  * @param FileWriter $writer Target file writer
  * @return FileWriter File writer instance
  * @throws RuntimeException If the resource cannot be copied
  */
 protected function copyToFile(FileWriter $writer)
 {
     // If a file resource is read
     if ($this->reader instanceof FileReader) {
         // If a copy error occurs
         if (!@copy($this->reader->getFile(), $writer->getFile())) {
             throw new RuntimeException(sprintf('Could not copy "%s" to "%s"', $this->reader->getFile(), $writer->getFile()), RuntimeException::COULD_NOT_COPY_FILE_TO_FILE);
         }
         return $writer;
     }
     // In-memory resource
     $writer->write($this->reader->read());
     return $writer;
 }
Esempio n. 2
0
 /**
  * Constructor
  *
  * @param string $file File path
  * @param int $options File options
  */
 public function __construct($file, $options = self::FILE_OVERWRITE)
 {
     parent::__construct($file, $options | self::FILE_OVERWRITE);
     // Validate the file
     $this->validateReaderFile();
 }