ZIP.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace ZN\Compression\Drivers;
  3. use ZN\Compression\CompressInterface;
  4. class ZipDriver implements CompressInterface
  5. {
  6. //----------------------------------------------------------------------------------------------------
  7. //
  8. // Yazar : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  9. // Site : www.zntr.net
  10. // Lisans : The MIT License
  11. // Telif Hakkı: Copyright (c) 2012-2016, zntr.net
  12. //
  13. //----------------------------------------------------------------------------------------------------
  14. /******************************************************************************************
  15. * EXRACT *
  16. *******************************************************************************************
  17. | Genel Kullanım: File::zipExtract() yöntemi ile aynı kullanıma sahiptir. |
  18. | |
  19. ******************************************************************************************/
  20. public function extract($source = '', $target = '', $password = NULL)
  21. {
  22. return \File::zipExtract($source, $target);
  23. }
  24. public function write($file = NULL, $data = NULL, $mode = NULL)
  25. {
  26. // Bu sürücü tarafından desteklenmemektedir!
  27. return false;
  28. }
  29. /******************************************************************************************
  30. * READ *
  31. *******************************************************************************************
  32. | Genel Kullanım: Sıkıştırılmış veriyi dosyadan okur. |
  33. | |
  34. ******************************************************************************************/
  35. public function read($file = '', $length = 1024, $mode = 'r')
  36. {
  37. if( ! is_string($file) || empty($file) )
  38. {
  39. return \Errors::set('Error', 'stringParameter', '1.(file)');
  40. }
  41. $open = zip_open($file);
  42. if( empty($open) )
  43. {
  44. return \Errors::set('Error', 'fileNotFound', $file);
  45. }
  46. $return = zip_read($open);
  47. zip_close($open);
  48. return $return;
  49. }
  50. public function compress($data = '', $blockSize = NULL, $workFactor = NULL)
  51. {
  52. // Bu sürücü tarafından desteklenmemektedir!
  53. return false;
  54. }
  55. public function uncompress($data = '', $small = 0)
  56. {
  57. // Bu sürücü tarafından desteklenmemektedir!
  58. return false;
  59. }
  60. public function encode($data = NULL, $level = NULL, $encoding = NULL)
  61. {
  62. // Bu sürücü tarafından desteklenmemektedir!
  63. return false;
  64. }
  65. public function decode($data = NULL, $length = NULL)
  66. {
  67. // Bu sürücü tarafından desteklenmemektedir!
  68. return false;
  69. }
  70. public function deflate($data = NULL, $level = NULL, $encoding = NULL)
  71. {
  72. // Bu sürücü tarafından desteklenmemektedir!
  73. return false;
  74. }
  75. public function inflate($data = NULL, $length = NULL)
  76. {
  77. // Bu sürücü tarafından desteklenmemektedir!
  78. return false;
  79. }
  80. }