PageRenderTime 46ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/good/ext/zip/tests/oo_delete.php

http://github.com/facebook/hiphop-php
PHP | 64 lines | 54 code | 10 blank | 0 comment | 14 complexity | 39ac205e00a321485daddd29191d9010 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh <<__EntryPoint>> function main(): void {
  2. $dirname = dirname(__FILE__) . '/';
  3. $file = $dirname . '__tmp_oo_delete.zip';
  4. if (file_exists($file)) {
  5. unlink($file);
  6. }
  7. $zip = new ZipArchive;
  8. if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
  9. exit('failed');
  10. }
  11. $zip->addFromString('entry1.txt', 'entry #1');
  12. $zip->addFromString('entry2.txt', 'entry #2');
  13. $zip->addFromString('dir/entry2.txt', 'entry #2');
  14. if ($zip->status == ZIPARCHIVE::ER_OK) {
  15. $zip->close();
  16. echo "ok\n";
  17. } else {
  18. var_dump($zip);
  19. echo "failed\n";
  20. }
  21. if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
  22. exit('failed');
  23. }
  24. if ($zip->deleteIndex(0)) {
  25. echo "ok\n";
  26. }
  27. if ($zip->deleteName('entry2.txt')) {
  28. echo "ok\n";
  29. } else {
  30. echo "failed 3\n";
  31. }
  32. if ($zip->deleteName('dir/entry2.txt')) {
  33. echo "ok\n";
  34. } else {
  35. echo "failed 3\n";
  36. }
  37. if (!$zip->deleteIndex(123)) {
  38. echo "ok\n";
  39. } else {
  40. print_r($zip);
  41. echo "failed\n";
  42. }
  43. $sb = $zip->statIndex(0);
  44. var_dump($sb);
  45. $sb = $zip->statIndex(1);
  46. var_dump($sb);
  47. $sb = $zip->statIndex(2);
  48. var_dump($sb);
  49. $zip->close();
  50. unset($zip);
  51. if (file_exists($file)) {
  52. unlink($file);
  53. }
  54. }