Stores data in a file.
@param String $path Absolute path within the server to a file where the data should be stored.
@param String &$data The data to store.
@return Boolean      Success status of the storage process.
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;
    }
179590
public static function delete($path)
	{
		if (is_dir($path)) {
			Dir::delete($path);
		} elseif (is_file($path)) {
			File::delete($path);
		}

		return true;
	}
1367537
public function createFile($path)
    {
        $node = $this->at($path);
        if ($node !== null && $node->type == 'dir') {
            return false;
        }

        $node = $this->at(dirname($path));
        if (null === $node) {
            return false;
        }

        $this->at($path, (object) [
            'type' => 'file',
            'perms' => 0664,
            'content' => ''
        ]);
        return true;
    }
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')
        );
    }
700068
public static function read($path)
    {
        $path = Normalize::diskFullPath($path);

        if (!self::exist($path)) {
            return false;
        }

        return @file_get_contents($path);
    }
86094
public function append($path): bool
    {
        $path = Normalize::diskFullPath($path);
        // check if file exist
        if (!File::exist($path)) {
            return false;
        }

        // load file translations
        $addTranslation = require($path);
        if (!Any::isArray($addTranslation)) {
            return false;
        }

        // merge data
        $this->cached = Arr::merge($this->cached, $addTranslation);
        return true;
    }
490272
public function saveDirectory(string $path) : bool
    {
        $this->obfuscated_path = rtrim($path, "/");
        if(is_dir($this->obfuscated_path) === false) {
            $this->addErrorMessage("The specified directory does not exist");
            return false;
        }

        if (is_writable($this->obfuscated_path) == false) {
            $this->addErrorMessage("No permissions to write to the directory");
            return false;
        }

        if ($this->obfuscateDirectoryDeep($this->plain_path, $this->obfuscated_path) == true ) {
            // Diretório ofuscado com sucesso,
            // gera o autoloader
            return $this->setupAutoloader();
        }

        return false;
    }
1334968
public function append($path, $data)
	{
		return $this->put($path, $this->get($path).PHP_EOL.$data);
	}
165494
public static function setByPath(&$data, $path, $value, $separator = '.')
    {
        if (false === strpos($path, $separator)) {
            $data[$path] = $value;

            return true;
        }

        if (!$nodes = Str::toArray($path, $separator)) {
            return false;
        }

        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (\is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    $dataTmp[$node] = [];
                }

                $dataTmp = &$dataTmp[$node];
            } else {
                // If a node is value but path is not go to the end, we replace this value as a new store.
                // Then next node can insert new value to this store.
                $dataTmp = array();
            }
        }

        // Now, path go to the end, means we get latest node, set value to this node.
        $dataTmp = $value;

        return true;
    }
266544
public function write($path, array $data = [])
    {
        return $this->post($this->buildPath($path), ['body' => json_encode($data)]);
    }
220102
public function downloadFile($path)
	{
		// Download contents of current file
		if (($data = $this->downloadData()) === null) {
			return false;
		}

		// Write contents to specified path
		if (@file_put_contents($path, $data) === false) {
			$this->error = array();
			$this->error['file'] = "Unable to write file '$path'";
			return false;
		}

		return true;
	}
303535
public static function get($path, $data = [])
	{
		ob_start();

		extract($data);

		try {
			$basePath = static::getInstance()->basePath;

			if ($basePath !== null) {
				if (mb_substr($path, 0, 1) === static::DIRECTORY_SEPARATOR) {
					$path = mb_substr($path, 1);
				}

				if (mb_substr($basePath, -1) === static::DIRECTORY_SEPARATOR) {
					$basePath = mb_substr($basePath, 0, -1);
				}

				$path = $basePath . static::DIRECTORY_SEPARATOR . $path;
			}

			include $path;
		} catch (\Exception $e) {
			ob_get_clean();
			throw $e;
		}

		return ob_get_clean();
	}
1352584
public function save($data)
	{
		if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
		{
			if ($data instanceof SimplePie)
			{
				$data = $data->data;
			}

			$data = serialize($data);
			return (bool) file_put_contents($this->name, $data);
		}
		return false;
	}
824946
protected function setResourceContents( $path, $content )
    {
        // Attempt to get file/resource sent from client/browser.
        $tempFile = $this->storeUploadedFile( $path, $content );
        eZWebDAVContentBackend::appendLogEntry( 'SetResourceContents:' . $path . ';' . $tempFile );

        // If there was an actual file:
        if ( !$tempFile )
        {
            return false; // @as self::FAILED_FORBIDDEN;
        }

        // Attempt to do something with it (copy/whatever).
        $fullPath = $path;
        $target = $this->splitFirstPathElement( $path, $currentSite );

        if ( !$currentSite )
        {
            return false; // @as self::FAILED_FORBIDDEN;
        }

        $result = $this->putVirtualFolderData( $currentSite, $target, $tempFile );

        unlink( $tempFile );
        eZDir::cleanupEmptyDirectories( dirname( $tempFile ) );

        return $result;
    }
416715
public function writeData($path = '', $data, $public = true)
    {
        $path = $this->getStoragePath($path);

        return $this->_storage->write($path, $data, $public);
    }
304245
public function append($path, $data)
	{
		if ($this->exists($path))
		{
			return $this->write($path, $this->read($path) . $data);
		}

		return $this->write($path, $data);
	}
637209
public function put($path = null, $data = [], array $options = []) {
		return $this->send(__FUNCTION__, $path, $data, $options);
	}