• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/io/csvfile.php
  • Класс: BitrixTranslateIOCsvFile
  • Вызов: CsvFile::fetchWidth
protected function fetchWidth(): ?array
{
	$str = '';
	$ind = 1;
	$jnd = 0;
	$result = [];

	while ($this->currentPosition <= $this->fileSize)
	{
		$ch = $this->buffer[$this->bufferPosition];
		if ($ch === "r" || $ch === "n")
		{
			while ($this->currentPosition <= $this->fileSize)
			{
				$this->incrementCurrentPosition();
				$ch = $this->buffer[$this->bufferPosition];
				if ($ch !== "r" && $ch !== "n")
				{
					break;
				}
			}
			if ($this->firstHeader)
			{
				$this->firstHeader = false;
				$result = [];
				$ind = 1;
				$str = '';
				continue;
			}

			$result[] = $str;

			return $result;
		}
		if ($ind === $this->widthMap[$jnd])
		{
			$result[] = $str. $ch;
			$str = '';
			$this->incrementCurrentPosition();
			$ind ++;
			$jnd ++;
			continue;
		}

		//inline "call"
		$this->currentPosition ++;
		$this->bufferPosition ++;
		if($this->bufferPosition >= $this->bufferSize)
		{
			$this->buffer = $this->read( 1024 * 1024);
			$this->bufferSize = $this->getStringByteLength($this->buffer);
			$this->bufferPosition = 0;
		}

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

	if ($str !== '')
	{
		$result[] = $str;
	}

	if ($result === [])
	{
		$result = null;
	}

	return $result;
}