1--TEST--
2ZipArchive::*ExternalAttributes*() function
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7
8$name = __DIR__ . '/withattr.zip';
9
10echo "== Set\n";
11$zip = new ZipArchive;
12$r = $zip->open($name, ZIPARCHIVE::CREATE);
13$zip->addFromString('foo.txt', 'foo');
14$zip->addFromString('bar.txt', 'bar');
15var_dump($zip->setExternalAttributesName('foo.txt', ZipArchive::OPSYS_UNIX, 123));
16$id = $zip->locateName('bar.txt');
17var_dump($zip->setExternalAttributesIndex($id, ZipArchive::OPSYS_VFAT, 234));
18$zip->close();
19
20echo "== Get\n";
21$r = $zip->open($name);
22var_dump($zip->getExternalAttributesName('foo.txt', $a, $b), $a, $b);
23$id = $zip->locateName('bar.txt');
24var_dump($zip->getExternalAttributesIndex($id, $a, $b), $a, $b);
25
26echo "== Set\n";
27var_dump($zip->setExternalAttributesName('foo.txt', ZipArchive::OPSYS_DOS, 345));
28var_dump($zip->setExternalAttributesIndex($id, ZipArchive::OPSYS_AMIGA, 456));
29echo "== Get changed\n";
30var_dump($zip->getExternalAttributesName('foo.txt', $a, $b), $a, $b);
31var_dump($zip->getExternalAttributesIndex($id, $a, $b), $a, $b);
32echo "== Get unchanged\n";
33var_dump($zip->getExternalAttributesName('foo.txt', $a, $b, ZipArchive::FL_UNCHANGED), $a, $b);
34var_dump($zip->getExternalAttributesIndex($id, $a, $b, ZipArchive::FL_UNCHANGED), $a, $b);
35
36$zip->close();
37?>
38== Done
39--CLEAN--
40<?php
41$name = __DIR__ . '/withattr.zip';
42@unlink($name);
43?>
44--EXPECT--
45== Set
46bool(true)
47bool(true)
48== Get
49bool(true)
50int(3)
51int(123)
52bool(true)
53int(14)
54int(234)
55== Set
56bool(true)
57bool(true)
58== Get changed
59bool(true)
60int(0)
61int(345)
62bool(true)
63int(1)
64int(456)
65== Get unchanged
66bool(true)
67int(3)
68int(123)
69bool(true)
70int(14)
71int(234)
72== Done
73