Write the data to the specified file.
Only available to Admin.
@param string $filename Relative to the Maps path
@param string $localFilename
@param bool $multicall
@return bool
@throws InvalidArgumentException
185127
function writeFileFromFile($filename, $localFilename, $multicall = false)
    {
        if (!file_exists($localFilename)) {
            throw new InvalidArgumentException('localFilename = ' . print_r($localFilename, true));
        }

        $contents = file_get_contents($localFilename);
        return $this->writeFile($filename, $contents, $multicall);
    }
290418
protected function assertFile($name)
    {
        if (strpos($name, '..') !== false) {
            throw new \InvalidArgumentException("File name '$name' isn't valid");
        }
        
        $file = $this->getFilePath($name);
        
        if (!file_exists($file)) {
            throw new \RuntimeException("View file '$file' doesn't exist");
        }
    }
1113450
protected function setFilename($filename)
    {
        if (is_string($filename)) {
            if (is_readable($filename)) {
                $this->filename = $filename;
            } elseif (file_exists($filename)) {
                throw new \InvalidArgumentException("File '$filename' isn't readable.");
            } else {
                throw new \InvalidArgumentException("File '$filename' doesn't exist.");
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($filename). "' for argument 'filename' given."
            );
        }

        return $this;
    }
643972
public function uploadFileToRemoteSpace(string $localFileName): string
    {
        if (!preg_match('#[\w\\\/\.]*\.zip$#', $localFileName)) {
            throw new \InvalidArgumentException('Zip archive required to upload to remote browser machine.');
        }

        $localFile = sprintf('%s%s', $this->getMinkParameter('files_path'), $localFileName);

        return $this->getSession()->getDriver()->getWebDriverSession()->file([
            'file' => base64_encode(file_get_contents($localFile)),
        ]);
    }
1098144
public function setLocalPath($localPath)
    {
        if (!file_exists($localPath)) {
            throw new InvalidArgumentException(sprintf('File %s does not exist', $localPath));
        }

        $this->localPath = $localPath;
    }
386718
protected function writeFile(string $filename, string $content): void
    {
        try {
            $f = \fopen($filename, 'w');
            \fwrite($f, $content, \mb_strlen($content));
            \fclose($f);
        } catch (\Throwable $e) {
            throw new WriterException($e->getMessage(), $e->getCode(), $e);
        }
    }
188829
public function rename(LibraryType $library, DirectoryItem $dirItem, string $newFilename): bool
    {
        $filePath = $dirItem->dir . $dirItem->name;

        if (empty($filePath)) {
            throw new \InvalidArgumentException('Invalid file path: must not be empty');
        }

        if (empty($newFilename) || strpos($newFilename, '/') === 0) {
            throw new \InvalidArgumentException('Invalid new file name: length must be >0 and must not start with /');
        }

        $uri = sprintf(
            '%s/repos/%s/file/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $library->id,
            $this->urlEncodePath($filePath)
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'operation',
                        'contents' => 'rename',
                    ],
                    [
                        'name'     => 'newname',
                        'contents' => $newFilename,
                    ],
                ],
            ]
        );

        $success = $response->getStatusCode() === 200;

        if ($success) {
            $dirItem->name = $newFilename;
        }

        return $success;
    }
366470
function sendToServerAfterMatchEnd($link, $multicall = false)
    {
        if (!is_string($link)) {
            throw new InvalidArgumentException('link = ' . print_r($link, true));
        }

        $link = str_replace("maniaplanet://", "", $link);

        return $this->execute(ucfirst(__FUNCTION__), array($link), $multicall);
    }
1097522
public static function writeFile($fileName, $content, $flags = 0)
    {
        if (Coroutine::isIn()) {
            return Coroutine::writeFile($fileName, $content, $flags);
        } else {
            return false !== file_put_contents($fileName, $content, $flags);
        }
    }
106251
private function writeFilename($filename, $data)
    {
        $f = fopen($filename, "w+");

        fwrite($f, implode('', $data));
        fclose($f);
    }
962587
public function save(File $file, $filename = null)
    {
        if ($filename !== null) {
            $file->setFilename($filename);
        }

        $this->filesystem->write($file);
    }
159081
protected function writeCacheFile($filename, $data)
	{
		$dir = pathinfo($filename, PATHINFO_DIRNAME);

		if (!file_exists($dir))
		{
			$mod = $this->options['chmod'] ? $this->options['chmod'] : 0777;
			mkdir($dir, $mod);
		}

		$isNew  = !file_exists($filename);
		$result = file_put_contents($filename, serialize($data), LOCK_EX) !== false;

		if ($isNew && $result !== false && $this->options['chmod'])
		{
			chmod($filename, $this->options['chmod']);
		}

		return $result;
	}
158083
function setApiVersion($version, $multicall = false)
    {
        if (!is_string($version)) {
            throw new InvalidArgumentException('version = ' . print_r($version, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($version), $multicall);
    }
513091
public function deleteDummyFile($fileName)
    {
        $absolutePathToFile = $this->getUploadFolderPath() . $fileName;
        $fileExists = file_exists($absolutePathToFile);

        if (!isset($this->dummyFiles[$fileName])) {
            throw new \InvalidArgumentException(
                'The file "' . $absolutePathToFile . '" which you are trying to delete ' .
                (!$fileExists ? 'does not exist and has never been ' : 'was not ') .
                'created by this instance of the testing framework.',
                1334439315
            );
        }

        if ($fileExists && !unlink($absolutePathToFile)) {
            throw new Exception('The file "' . $absolutePathToFile . '" could not be deleted.', 1334439327);
        }

        unset($this->dummyFiles[$fileName]);
    }
954499
private function writeFile(fDOMDocument $dom, $filename)
    {
        $dom->formatOutput = true;
        $result = $dom->save($filename);

        return ($result !== false) ? true : false;
    }
732179
function setCallVoteTimeOut($timeout, $multicall = false)
    {
        if (!is_int($timeout)) {
            throw new InvalidArgumentException('timeout = ' . print_r($timeout, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($timeout), $multicall);
    }
739578
public function rename($name)
    {
        $this->guardDeletedFile();

        // If there is any slash character in new name, Selectel
        // will create new virtual directory and copy file to
        // this new one. Such behaviour may be unexpected.

        if (count(explode('/', $name)) > 1) {
            throw new InvalidArgumentException('File name can not contain "/" character.');
        }

        $destination = $this->directory().'/'.$name;

        $response = $this->api->request('PUT', $this->absolutePath($destination), [
            'headers' => [
                'X-Copy-From' => $this->absolutePath(),
                'Content-Length' => 0,
            ],
        ]);

        if ($response->getStatusCode() !== 201) {
            throw new ApiRequestFailedException(
                'Unable to rename file from "'.$this->name().'" to "'.$name.'" (path: "'.$this->directory().'").',
                $response->getStatusCode()
            );
        }

        // Since Selectel Storage does not provide such method as "rename",
        // we need to delete original file after copying. Also, "deleted"
        // flag needs to be reverted because file was actually renamed.

        $this->delete();
        $this->deleted = false;

        return $this->data['name'] = $destination;
    }