read())) { if ($entry != '.' && $entry != '..') { $obj = Files::fixPath($folder).$entry; //var_dump($obj); if (is_file($obj)) { $deleted &= Files::delFile($obj); } else if(is_dir($obj)) { $deleted &= Files::delFolder($obj, $recursive); } } } $d->close(); } //$folder= $folder.'/thumbs'; //var_dump($folder); if(is_dir($folder)) $deleted &= rmdir($folder); else $deleted &= false; Return $deleted; } /** * Append a / to the path if required. * @param string $path the path * @return string path with trailing / */ function fixPath($path) { //append a slash to the path if it doesn't exists. if(!(substr($path,-1) == '/')) $path .= '/'; Return $path; } /** * Concat two paths together. Basically $pathA+$pathB * @param string $pathA path one * @param string $pathB path two * @return string a trailing slash combinded path. */ function makePath($pathA, $pathB) { $pathA = Files::fixPath($pathA); if(substr($pathB,0,1)=='/') $pathB = substr($pathB,1); Return Files::fixPath($pathA.$pathB); } /** * Similar to makePath, but the second parameter * is not only a path, it may contain say a file ending. * @param string $pathA the leading path * @param string $pathB the ending path with file * @return string combined file path. */ function makeFile($pathA, $pathB) { $pathA = Files::fixPath($pathA); if(substr($pathB,0,1)=='/') $pathB = substr($pathB,1); Return $pathA.$pathB; } /** * Format the file size, limits to Mb. * @param int $size the raw filesize * @return string formated file size. */ function formatSize($size) { if($size < 1024) return $size.' bytes'; else if($size >= 1024 && $size < 1024*1024) return sprintf('%01.2f',$size/1024.0).' Kb'; else return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; } } ?>