Stores string data at a given path

@param $data
@param $filePath
@return bool
@throws \Magento\Framework\Exception\FileSystemException
@throws \Exception
165521
protected function storeFile($data, $filePath)
    {
        // create a folder for message if needed
        if (!is_dir(dirname($filePath))) {
            $this->createFolder(dirname($filePath));
        }

        /** @noinspection LoopWhichDoesNotLoopInspection */
        for ($i = 0; $i < $this->_config->getHostRetryLimit(); $i++) {
            /* We try an exclusive creation of the file.
             * This is an atomic operation, it avoid locking mechanism
             */
            $fp = @fopen($filePath, 'x');

            if($fp !== false) {
                if (false === fwrite($fp, $data)) {
                    return false;
                }

                fclose($fp);

                return $filePath;
            }
        }

        throw new FileSystemException(
            new Phrase('Unable to create a file for enqueuing Message')
        );
    }
966880
function delete_file($filepath)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		$result = @ftp_delete($this->_conn_id, $filepath);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('Unable to delete');
			}
			return false;
		}

		return true;
	}
886575
public function locate($filePath)
    {
        $file = $filePath;
        if (!is_file($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" does not exist.',
                                            $filePath));
        }

        if (!is_readable($filePath))
        {
            throw new FileException(sprintf('Invalid file! File "%s" is not readable.',
                                            $filePath));
        }

        $pathInfo = pathinfo($filePath);
        if (!isset($pathInfo['extension'])
            || !in_array($pathInfo['extension'], $this->supportedExtensions)
        )
        {
            throw new FileException(sprintf('Invalid file extension! Supported file extensions: %s',
                implode(', ', $this->supportedExtensions)));
        }

        return realpath($file);
    }
178954
protected function setFilePath($filePath)
	{
		if ( ! is_string($filePath))
		{
			throw new \InvalidArgumentException('File path must be a string type.');
		}
		
		if (preg_match('~^(\w+:)?//~', $filePath) || is_link($filePath))
		{
			throw new \InvalidArgumentException('File path must be a local path.');
		}
		
		$filePath = realpath($filePath);
		
		if ( ! is_file($filePath))
		{
			throw new TranscoderException('File path not found.');
		}
		
		$this->filePath = $filePath;
		
		return $this;
	}
654577
private function saveToFilesystem($filePath, $file)
    {
        if (!file_exists("." . $filePath)) {
            $fp = fopen("." . $filePath, "w");
            fputs($fp, $file['data']);
            fclose($fp);
        }
    }
568093
protected function putIntoFile($file_path, $data)
    {
        if ($this->files->isDirectory($this->files->dirname($file_path))) {
            $data = str_replace(["\n", "\r"], '', trim((string) $data));

            return $this->files->put($file_path, $data, $this->use_locking) > 0;
        }

        // @codeCoverageIgnoreStart
        return false;
        // @codeCoverageIgnoreEnd
    }
929135
private static void loadFile(String filePath) {
        final Path path = FileSystems.getDefault().getPath(filePath);

        try {
            data.clear();
            data.load(Files.newBufferedReader(path));
        } catch(IOException e) {
            LOG.warn("Exception while loading " + path.toString(), e);
        }
    }
1246968
public static function isValid(string $filePath): bool
    {
        return self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            });
    }
422798
public function store($path, &$data) {
        $ssh = $this->getSshSession();
        $sftp = ssh2_sftp($ssh);

        $sftpStream = @fopen('ssh2.sftp://' . $sftp . $path, 'wb');

        if (!$sftpStream) {
            throw new Exception("Could not open remote file: $path");
        }

        if (@fwrite($sftpStream, $data) === false) {
            throw new Exception("Could not store {$path} by SFTP on " . $this->getEnvironment());
        }

        fclose($sftpStream);
        return true;
    }
762866
public static function unlinkSafe(string $filePath) : bool
    {
        if (!FileHelper::fileExistsSafe($filePath)) {
            return false;
        }

        if (DirHelper::isDirSafe($filePath)) {
            return false;
        }

        return unlink($filePath);
    }
497296
public static function save( $filePath, $value, $format = FALSE )
	{
		$writer	= new FS_File_JSON_Writer( $filePath );
		return $writer->write( $value, $format );
	}
993401
public function setFile($filePath)
    {
        if (is_file($filePath)) {
            $this->file = new SplFileInfo($filePath);

            if (file_exists(
                $propertiesFilePath = $this->file->getPath() . DIRECTORY_SEPARATOR . str_replace(
                        '.phtml',
                        '.json',
                        strtolower($this->file->getBasename())
                    )
            )) {
                $properties = file_get_contents($propertiesFilePath);
                $properties = json_decode($properties, true);

                if (isset($properties[ 'vars' ])) {
                    $this->vars = $properties[ 'vars' ];
                }

                if (isset($properties[ 'presets' ])) {
                    $this->presets = new SplArrayObject($properties[ 'presets' ]);
                }
            }
        }

        return $this;
    }
822128
public static function loadFromPhpFile(string $filePath): DataMap
    {
        if (! is_file($filePath)) {
            throw new CoreException(CoreException::FILE_NOT_FOUND, '找不到php文件: ' . $filePath, $filePath);
        }
        $data = include $filePath;
        return new static($data);
    }
56804
function save($filepath='') {
        $ret = $this->root->innertext();
        if ($filepath!=='') file_put_contents($filepath, $ret);
        return $ret;
    }
81245
public function setFile(string $filePath): self
    {
        IOExpect::isFile($filePath);
        IOExpect::isReadable($filePath);

        $this->file = $filePath;

        return $this;
    }
775291
public function setFilePath( $filePath )
	{
		$this->filePath      = $filePath;
		$this->shortFilePath = str_replace( base_path() , '' , $filePath );

		return $this;
	}
796099
protected function createDirectory($filePath)
    {
        $parts = explode('/', $filePath);
        $file = array_pop($parts);
        $dir = '';
        foreach ($parts as $part) {
            if (!is_dir($dir .= "/$part")) {
                mkdir($dir);
            }
        }
    }