function test_mkdirs_1() { @ini_set('track_errors', true); $php_errormsg = ''; $dir = FREEBEER_BASE . '/var/tmp/test1/test2/test3'; $rv = fbFile::mkdirs($dir); $this->assertTrue($rv, "mkdirs() failed"); $this->assertTrue(@is_dir($dir), "mkdirs() failed to create '{$dir}': {$php_errormsg}"); rmdir($dir); rmdir(dirname($dir)); rmdir(dirname(dirname($dir))); }
function mkdirs($path, $rights = 0777, $umask = null) { if (!$path) { return false; } if (@is_dir($path)) { return true; } $dirname = dirname($path); if ($dirname == $path) { // we've reached / or c:\ return false; } $track_errors = @ini_set('track_errors', true); $php_errormsg = ''; $rv = false; do { if (!@is_dir($dirname)) { if (!fbFile::mkdirs($dirname, $rights)) { break; } } if (!is_null($umask)) { $saved_umask = @umask(); @umask($umask); } $rv = @mkdir($path, $rights); if (!is_null($umask)) { @umask($saved_umask); } if (!$rv) { trigger_error(sprintf('Could not create directory \'%s\': %s', $path, $php_errormsg)); } } while (false); if (!$track_errors) { @ini_set('track_errors', $track_errors); } return $rv; }
$full_testname2 = strtr($full_testname2, '.', '_'); $full_testname2 = strtr($full_testname2, '-', '_'); echo "file={$file}\nfull_testname={$full_testname}\nd={$d}\nfull_testname2={$full_testname2}\n"; $phpunit_code = ''; if ($full_testname2 != $testname) { $phpunit_code = "\n# make PHPUnit_GUI_SetupDecorator() happy\nclass _{$full_testname2} extends _{$testname} {\n}\n"; } //echo "testname=$testname\n"; if ($after_lib_name) { $test = $test_dir . '/' . $after_lib_name . '/' . $testname . '.php'; } else { $test = $test_dir . '/' . $testname . '.php'; } //echo "test=$test\n"; if (!@is_dir($test_dir . '/' . $after_lib_name)) { fbFile::mkdirs($test_dir . '/' . $after_lib_name, 0777, 00); } $exists = is_file($test); if ($exists) { $filesize = filesize($test); } $fp = fopen($test, 'a+b'); if (!$fp) { die("Can't open {$test}: {$php_errormsg}"); } if ($after_lib_name) { $after_lib_name .= '/'; } if (!$exists) { $data = <<<EOD <?php