Archive_Tar::_addList PHP Method

_addList() public method

{{{ _addList()
public _addList ( $p_list, $p_add_dir, $p_remove_dir )
    function _addList($p_list, $p_add_dir, $p_remove_dir)
    {
        $v_result = true;
        $v_header = array();
        // ----- Remove potential windows directory separator
        $p_add_dir = $this->_translateWinPath($p_add_dir);
        $p_remove_dir = $this->_translateWinPath($p_remove_dir, false);
        if (!$this->_file) {
            $this->_error('Invalid file descriptor');
            return false;
        }
        if (sizeof($p_list) == 0) {
            return true;
        }
        foreach ($p_list as $v_filename) {
            if (!$v_result) {
                break;
            }
            // ----- Skip the current tar name
            if ($v_filename == $this->_tarname) {
                continue;
            }
            if ($v_filename == '') {
                continue;
            }
            if (!file_exists($v_filename)) {
                $this->_warning("File '{$v_filename}' does not exist");
                continue;
            }
            // ----- Add the file or directory header
            if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) {
                return false;
            }
            if (@is_dir($v_filename) && !@is_link($v_filename)) {
                if (!($p_hdir = opendir($v_filename))) {
                    $this->_warning("Directory '{$v_filename}' can not be read");
                    continue;
                }
                while (false !== ($p_hitem = readdir($p_hdir))) {
                    if ($p_hitem != '.' && $p_hitem != '..') {
                        if ($v_filename != ".") {
                            $p_temp_list[0] = $v_filename . '/' . $p_hitem;
                        } else {
                            $p_temp_list[0] = $p_hitem;
                        }
                        $v_result = $this->_addList($p_temp_list, $p_add_dir, $p_remove_dir);
                    }
                }
                unset($p_temp_list);
                unset($p_hdir);
                unset($p_hitem);
            }
        }
        return $v_result;
    }