Blame view

common/components/archives/ZipArchiveReader.php 886 Bytes
c4da20f0   Mihail   temp commit - tes...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  <?php
  /**
   * Created by PhpStorm.
   * User: Tsurkanov
   * Date: 03.11.2015
   * Time: 15:12
   */
  
  namespace common\components\archives;
  
  
  class ZipArchiveReader extends  ArchiveReader {
  
      protected $resource;
      public  function open( $file, $password = '' ){
          $zip = new \ZipArchive;
          $this->resource = $zip->open( $file );
          if ($this->resource === FALSE)
              throw new \Exception("Failed opening zip file");
      }
  
      public  function extractTo( $destination){
  
              $this->resource->extractTo($destination);
  
          for ($i = 0; $i < $this->resource->numFiles; $i++) {
              $filename = $this->resource->getNameIndex($i);
              $this->setExtractedFiles($filename, pathinfo($filename, PATHINFO_EXTENSION));
          }
  
          $this->resource->close();
      }
      public static  function getExtension(){
          return 'rar';
      }
  
  
  
  
  }