* @package helpers */ class helpers_VersionedFile { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- /** * Short description of method deleteFiles * * @access public * @author Somsack Sipasseuth, * @param array files * @return boolean */ public static function deleteFiles($files = []) { $returnValue = (bool) false; return (bool) $returnValue; } /** * Short description of method rmWorkingCopy * * @access public * @author Somsack Sipasseuth, * @param string path * @param boolean recursive * @return boolean */ public static function rmWorkingCopy($path, $recursive = true) { $returnValue = (bool) false; if (is_file($path)) { if (preg_match('/^\//', $path)) { $returnValue = @unlink($path); } } elseif ($recursive) { if (is_dir($path)) { $iterator = new DirectoryIterator($path); foreach ($iterator as $fileinfo) { if (!$fileinfo->isDot()) { self::rmWorkingCopy($fileinfo->getPathname(), true); } unset($fileinfo); } unset($iterator); $returnValue = @rmdir($path); } } return (bool) $returnValue; } /** * Short description of method cpWorkingCopy * * @access public * @author Somsack Sipasseuth, * @param string source * @param string destination * @param boolean recursive * @param boolean ignoreSystemFiles * @return boolean */ public static function cpWorkingCopy($source, $destination, $recursive = true, $ignoreSystemFiles = true) { $returnValue = (bool) false; if (file_exists($source)) { if (is_dir($source) && $recursive) { foreach (scandir($source) as $file) { if ($file != '.' && $file != '..' && $file != '.svn') { if (!$ignoreSystemFiles && $file[0] == '.') { continue; } else { self::cpWorkingCopy($source . '/' . $file, $destination . '/' . $file, true, $ignoreSystemFiles); } } } } else { if (is_dir(dirname($destination))) { $returnValue = copy($source, $destination); } elseif ($recursive) { if (mkdir(dirname($destination), 0775, true)) { $returnValue = self::cpWorkingCopy($source, $destination, false, $ignoreSystemFiles); } } } } return (bool) $returnValue; } }