4 * Helper class with some filesystem utilities.
9 * converts path to unix-like on windows OS
10 * @param string $path UNIX-like path to be converted
13 public static function w2u($path) {
14 return isWindows() ?
str_replace('\\', '/', $path) : $path;
18 * helper for recursive copy()
21 * @param $destdir string
22 * @param $source string
24 public static function rcopy($destdir, $source) {
25 if (!is_dir($source)) {
26 copy($source, $destdir.'/'.basename($source));
28 $newdestdir = $destdir.'/'.basename($source);
29 if (!is_dir($newdestdir)) {
34 while (false !== ($entry = $dh->read())) {
35 if ($entry == '.' ||
$entry == '..') {
38 TestUtils
::rcopy($newdestdir, $source.'/'.$entry);
45 * helper for recursive rmdir()/unlink()
48 * @param $target string
50 public static function rdelete($target) {
51 if (!is_dir($target)) {
55 while (false !== ($entry = $dh->read())) {
56 if ($entry == '.' ||
$entry == '..') {
59 TestUtils
::rdelete("$target/$entry");
67 * helper to append text to a file
73 public static function fappend($file, $text) {
74 $fh = fopen($file, 'a');