示例#1
0
 /**
  *
  * @param \SplFileInfo $dir
  * @param type $recursive
  *
  * @return MediaCollection
  */
 public function inspectDirectory($dir, $recursive = false)
 {
     $this->reader->reset()->in($dir)->followSymLinks();
     if (!$recursive) {
         $this->reader->notRecursive();
     }
     $files = new MediaCollection();
     foreach ($this->reader as $entity) {
         $file = new File($entity->getFile());
         $classname = $this->guessFromMimeType($file->getMimeType());
         $files[] = new $classname($file, $entity, $this->writer, $this->ffprobe);
     }
     return $files;
 }
 /**
  * Generates a metadatas-free version of the file in the temporary directory
  *
  * @return string the path file to the temporary file
  */
 private function getTemporaryEmptyFile()
 {
     $tmpFile = tempnam(sys_get_temp_dir(), 'hash');
     unlink($tmpFile);
     try {
         $this->writer->reset();
         $this->writer->erase(true);
         $this->writer->write($this->file->getPathname(), new MetadataBag(), $tmpFile);
     } catch (PHPExiftoolExceptionInterface $e) {
         /**
          * Some files can not be written by exiftool
          */
         copy($this->file->getPathname(), $tmpFile);
     }
     $this->temporaryFiles[] = $tmpFile;
     return $tmpFile;
 }
示例#3
0
 /**
  * @covers MediaVorus\File::__construct
  * @covers MediaVorus\File::getMimeType
  */
 public function testGetMimeTypeApe()
 {
     $object = new File(__DIR__ . '/../../files/APE.ape');
     $this->assertEquals('audio/x-monkeys-audio', $object->getMimeType());
 }