/usr/share/php/tests/PHP_Compat/tests/function/mkdir.phpt is in php-compat 1.6.0a3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | --TEST--
Function -- mkdir
--FILE--
<?php
require_once 'PHP/Compat/Function/mkdir.php';
/**
* Delete a file, or a folder and its contents
*
* @author Aidan Lister <aidan@php.net>
* @version 1.0.3
* @link http://aidanlister.com/repos/v/function.rmdirr.php
* @param string $dirname Directory to delete
* @return bool Returns TRUE on success, FALSE on failure
*/
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname) || is_link($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
// Clean up
$dir->close();
return rmdir($dirname);
}
$base = realpath('.');
$tests = array(
array('foo'),
array('foo2', 'bar'),
array('foo3', 'bar', 'baz')
);
echo "\nabsolute paths:\n";
foreach ($tests as $v) {
array_unshift($v, $base);
$dir = implode(DIRECTORY_SEPARATOR, $v);
var_dump(php_compat_mkdir($dir, 0777, true), is_dir($dir));
}
// clean up
foreach ($tests as $v) {
rmdirr($v[0]);
}
echo "\nrelative paths:\n";
foreach ($tests as $v) {
$dir = implode(DIRECTORY_SEPARATOR, $v);
var_dump(php_compat_mkdir($dir, 0777, true), is_dir($dir));
}
// clean up
foreach ($tests as $v) {
rmdirr($v[0]);
}
?>
--EXPECT--
absolute paths:
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
relative paths:
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
|