File: oo_addfile_proc.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (50 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--TEST--
ziparchive::addFile() for dynamic files reported empty
--EXTENSIONS--
zip
--SKIPIF--
<?php
if (!file_exists('/proc/cpuinfo')) die('skip no /proc');
if (!defined('ZipArchive::LENGTH_UNCHECKED')) die('skip libzip too old');
?>
--FILE--
<?php

include __DIR__ . '/utils.inc';
$file = __DIR__ . '/__tmp_oo_addfile_proc.zip';

$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
	exit('failed');
}
if (!$zip->addFile('/proc/cpuinfo', 'cpu.txt', 0, ZipArchive::LENGTH_UNCHECKED)) {
	echo "failed\n";
}
if (!$zip->addFile('/proc/meminfo', 'mem.txt', 0, ZipArchive::LENGTH_UNCHECKED)) {
	echo "failed\n";
}

if ($zip->status == ZIPARCHIVE::ER_OK) {
	dump_entries_name($zip);
	$zip->close();
} else {
	echo "failed\n";
}
var_dump($zip->status);

if (!$zip->open($file)) {
	exit('failed');
}
var_dump(strlen($zip->getFromName('cpu.txt')) > 0);
var_dump(strlen($zip->getFromName('mem.txt')) > 0);

@unlink($file);
?>
Done
--EXPECTF--
0 cpu.txt
1 mem.txt
int(0)
bool(true)
bool(true)
Done