1--TEST-- 2ziparchive::addEmptyDir 3--EXTENSIONS-- 4zip 5--FILE-- 6<?php 7 8$dirname = __DIR__ . '/'; 9include $dirname . 'utils.inc'; 10$file = $dirname . 'oo_addemptydir.zip'; 11 12copy($dirname . 'test.zip', $file); 13 14$zip = new ZipArchive; 15if (!$zip->open($file)) { 16 exit('failed'); 17} 18 19var_dump($zip->lastId); // -1 (nothing added) 20$zip->addEmptyDir('emptydir'); 21var_dump($zip->lastId); // 4 22$zip->addEmptyDir('emptydir'); 23var_dump($zip->lastId); // -1 (already exists) 24$zip->addEmptyDir('emptydir', ZipArchive::FL_OVERWRITE); 25var_dump($zip->lastId); // 4 26if ($zip->status == ZIPARCHIVE::ER_OK) { 27 if (!verify_entries($zip, [ 28 "bar", 29 "foobar/", 30 "foobar/baz", 31 "entry1.txt", 32 "emptydir/" 33 ])) { 34 echo "failed\n"; 35 } else { 36 echo "OK"; 37 } 38 $zip->close(); 39} else { 40 echo "failed3\n"; 41} 42@unlink($file); 43?> 44--EXPECT-- 45int(-1) 46int(4) 47int(-1) 48int(4) 49OK 50