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