• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/csv_data.php
  • Класс: CCSVData
  • Вызов: CCSVData::FetchWidth
public function FetchWidth()
{
	if (!$this->__file)
	{
		return false;
	}

	$str = "";
	$ind = 1;
	$jnd = 0;
	$res_r = array();

	while ($this->iCurPos < $this->iFileLength)
	{
		$ch = $this->__buffer[$this->__buffer_pos];
		if ($ch == "r" || $ch == "n")
		{
			while ($this->iCurPos < $this->iFileLength)
			{
				$this->IncCurPos();
				$ch = $this->__buffer[$this->__buffer_pos];
				if ($ch != "r" && $ch != "n")
				{
					break;
				}
			}
			if ($this->bFirstHeader)
			{
				$this->bFirstHeader = false;
				$res_r = array();
				$ind = 1;
				$str = "";
				continue;
			}
			else
			{
				$res_r[] = $str;
				return $res_r;
			}
		}
		elseif ($ind == $this->arWidthMap[$jnd])
		{
			$res_r[] = $str.$ch;
			$str = "";
			$this->IncCurPos();
			$ind++;
			$jnd++;
			continue;
		}

		//inline "call"
		$this->iCurPos++;
		$this->__buffer_pos++;
		if($this->__buffer_pos >= $this->__buffer_size)
		{
			if(feof($this->__file))
			{
				$this->__buffer = "";
			}
			else
			{
				$this->__buffer = fread($this->__file, 1024*1024);
			}
			$this->__buffer_size = strlen($this->__buffer);
			$this->__buffer_pos = 0;
		}

		$ind++;
		$str .= $ch;
	}

	if ($str <> '')
	{
		$res_r[] = $str;
	}

	if(empty($res_r))
	{
		return false;
	}
	else
	{
		return $res_r;
	}
}