<?php

/**
 * @version		$Id$
 * @package		ARTIO Booking 
 * @copyright	Copyright (C) 2010 ARTIO s.r.o.. All rights reserved.
 * @author 		ARTIO s.r.o., http://www.artio.net
 * @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * @link        http://www.artio.net Official website
 */

defined('_JEXEC') or die('Restricted access');

if (! defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}

class BookitReinstall
{

    public static function addFilesOp(&$instance, $target, $source, $recursive = true)
    {
        if (($directory = dir(($dir = realpath(dirname(__FILE__) . DS . '..' . DS . $source)))))
            while (($filename = $directory->read()) !== false)
                if (strpos($filename, '.') !== 0) {
                    if (is_file(($filepath = $dir . DS . $filename)))
                        $instance->_addFileOp(DS . $target . DS . $filename, 'upgrade', DS . $source . DS . $filename);
                    elseif (is_dir($filepath) && $recursive)
                        BookitReinstall::addFilesOp($instance, $target . DS . $filename, $source . DS . $filename);
                }
    }
}

?>