Example #1
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());
 }
Example #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);
 }
Example #3
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);
     }
 }