Writes to a file.  Also closes and releases any locks on the file.
@param resource $fh The file handle
@param FileSystemCacheValue $data The cache value to store in the file.
@return boolean True on success.  Currently, never returns false.
421038
private static function putContents($fh,FileSystemCacheValue $data) {
		try{
			fwrite($fh,serialize($data));
			fflush($fh);
		} catch (\Exception $ex){}

		//release lock
		self::closeFile($fh);

		return true;
	}
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;
	}
922065
public function write(File $file)
    {
        $success = file_put_contents(
            $this->getRouteCachePath($file->getRoute()),
            $file->toString()
        );
        if ($success === false) {
            throw new CacheFileSystemException(
                "Unable to save Cache file to disk in file " . $this->getRouteCachePath($file->getRoute())
            );
        }
    }
611688
public function store($id, $data)
    {
        $flag = $this->locking ? LOCK_EX : null;
        $file = $this->path . '/' . $id;

        if (! @file_put_contents($file, $data, $flag)) {
            $this->logger->warning("Minify_Cache_File: Write failed to '$file'");
        }

        // write control
        if ($data !== $this->fetch($id)) {
            @unlink($file);
            $this->logger->warning("Minify_Cache_File: Post-write read failed for '$file'");

            return false;
        }

        return true;
    }
128875
public function write($data, $cb = null, $offset = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if ($data === '') {
            if ($cb) {
                $cb($this, 0);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($offset !== null) {
                fseek($data, $offset);
            }
            $r = fwrite($this->fd, $data);
            if ($cb) {
                $cb($this, $r);
            }
            return false;
        }
        if ($cb !== null) {
            $this->onWriteOnce->push($cb);
        }
        $l = mb_orig_strlen($data);
        if ($offset === null) {
            $offset = $this->offset;
            $this->offset += $l;
        }
        $this->writing = true;
        $res = eio_write(
            $this->fd,
            $data,
            $l,
            $offset,
            $pri,
            function ($file, $result) {
                $this->writing = false;
                $this->onWriteOnce->executeAll($file, $result);
            },
            $this
        );
        return $res;
    }
1169963
public function write($data)
    {
        if (!$this->connected && !$this->connect()) {
            return false;
        }
        $totalBytes = strlen($data);
        $written = 0;
        while ($written < $totalBytes) {
            $rv = fwrite($this->connection, substr($data, $written));
            if ($rv === false || $rv === 0) {
                return $written;
            }
            $written += $rv;
        }

        return $written;
    }
363560
protected function _write($data) {
		if (!$this->connected && !$this->connect()) {
			return false;
		}

		$data .= "\r\n";
		return fwrite($this->_connection, $data, strlen($data));
	}
354035
public function store($hash, $data)
    {
        $modified = file_exists($hash) ? filemtime($hash) : 0;
        if ($modified) {
            $this->updateRegistry();
            $md5hash = HashHandler::getInstance()->calculate($hash);
            if (isset($this->storage[$md5hash])) {
                $oldFileName = $md5hash . '_' . $this->storage[$md5hash] . '.php';
                if (file_exists($this->saveDirPath . '/' . $oldFileName)) {
                    unlink($this->saveDirPath . '/' . $oldFileName);
                }
            }
            $newFileName = $md5hash . '_' . $modified . '.php';
            if ($f = fopen($this->saveDirPath . '/' . $newFileName, 'w')) {
                fputs($f, '<?php return ' . var_export($data, true) . ';');
                fclose($f);
                $this->storage[$md5hash] = $modified;
            } else {
                throw new \Exception('Can not write to config cache directory');
            }
            $this->dumpRegistry();
        }
    }
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')
        );
    }
213967
private function writeFile($filePath, $data)
    {
        $fh = fopen($filePath, 'w+');
        fwrite($fh, $data);
        fclose($fh);
    }
893594
protected function writebytes($data)
    {
        if (!$this->file) {
            $this->memory .= $data;
            $written = strlen($data);
        } else {
            $written = @fwrite($this->fh, $data);
        }
        if ($written === false) {
            throw new ArchiveIOException('Failed to write to archive stream');
        }
        return $written;
    }
32608
public static function fwrite($fh, $string)
    {
        for ($written = 0; $written < strlen($string); $written += $fwrite) {
            if (($fwrite = fwrite($fh, substr($string, $written))) === false) {
                return $written;
            }
        }

        return $written;
    }
1281255
public function writeln($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bevWrite)) {
            return false;
        }
        if (!mb_orig_strlen($data) && !mb_orig_strlen($this->EOL)) {
            return true;
        }
        $this->writing = true;
        $this->bevWrite->write($data);
        $this->bevWrite->write($this->EOL);
        return true;
    }
461529
protected function writeFileProcess( string $file, \Closure $data, bool $append = false )
	{
		return $this->write(
			$file, $data, $append
		);
	}
142980
public function write($fileName, $content, $expiry = false)
    {
        if($this->_cache_manager) {
            $_file_name = $this->getFileName($fileName);
            return $this->_cache_manager->setItem($_file_name, serialize($content));
        }

        return false;
    }
1018782
public function write($id, $data)
    {
        // Only store session to disk if data exists or session already
        // existed before (in last case we always want to touch the file
        // to prevent early garbage collection)
        // Note: This logic can be overwritten by the force flag
        if ($data
            || $this->exists
            || $this->force
        ) {
            $file = $this->getPathForSessionId($id);
            file_put_contents($file, $data);
            chmod($file, 0600);
            $this->exists = true;
        }

        return true;
    }
174363
private static function write($content)
	{
		self::lock();
		if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
		ftruncate( self::$authFileP , 0 );
		fwrite( self::$authFileP , $content );

		return fflush( self::$authFileP );
	}