Пример #1
0
 /**
  * Constructs the Ogg class with given file.
  *
  * @param string $filename The path to the file.
  * @throws HausDesign_Io_Exception if an error occur in stream handling.
  * @throws HausDesign_Media_Ogg_Exception if an error occurs in Ogg bitstream reading.
  */
 public function __construct($filename)
 {
     $reader = new HausDesign_Io_FileReader($filename);
     $fileSize = $reader->getSize();
     while ($reader->getOffset() < $fileSize) {
         $this->_pages[] = array('offset' => $reader->getOffset(), 'page' => $page = new HausDesign_Media_Ogg_Page($reader));
         $this->_size += $page->getPageSize();
         $reader->skip($page->getPageSize());
     }
     $reader->setOffset($this->_pages[$this->_currentPageNumber]['offset'] + $this->_pages[$this->_currentPageNumber]['page']->getHeaderSize());
     $this->_fd = $reader->getFileDescriptor();
 }
Пример #2
0
 /**
  * Removes the ID3v2 tag altogether.
  *
  * @param string $filename The path to the file.
  */
 public static function remove($filename)
 {
     if ($filename instanceof HausDesign_Io_Reader) {
         $reader =& $filename;
     } else {
         require_once 'HausDesign/Io/FileReader.php';
         $reader = new HausDesign_Io_FileReader($filename, 'r+b');
     }
     $fileSize = $reader->getSize();
     if ($reader->read(3) == 'ID3') {
         $header = new HausDesign_Media_Id3_Header($reader);
         $tagSize = 10 + $header->getSize();
     } else {
         return;
     }
     $fd = $reader->getFileDescriptor();
     for ($i = 0; $tagSize + $i * 1024 < $fileSize; $i++) {
         fseek($fd, $tagSize + $i * 1024);
         $buffer = fread($fd, 1024);
         fseek($fd, $i * 1024);
         $bytes = fwrite($fd, $buffer, 1024);
     }
     ftruncate($fd, $fileSize - $tagSize);
 }
Пример #3
0
 /**
  * Reads the magic information from given magic file.
  *
  * @param string $filename The path to the magic file.
  */
 public function __construct($filename)
 {
     $reader = new HausDesign_Io_FileReader($filename);
     $this->_magic = $reader->read($reader->getSize());
 }
Пример #4
0
 /**
  * Removes the ID3v1 tag altogether.
  *
  * @param string $filename The path to the file.
  */
 public static function remove($filename)
 {
     $reader = new HausDesign_Io_FileReader($filename, 'r+b');
     $reader->setOffset(-128);
     if ($reader->read(3) == 'TAG') {
         ftruncate($reader->getFileDescriptor(), $reader->getSize() - 128);
     }
 }