Write a string to a file

@param  string  $path     file path
@param  string  $content  new file content
@return bool
@author Dmitry (dio) Levashov
503017
protected function _filePutContents($path, $content) {
		$res = false;

		if ($this->tmp) {
			$local = $this->getTempFile();
			
			if (@file_put_contents($local, $content, LOCK_EX) !== false
			&& ($fp = @fopen($local, 'rb'))) {
				clearstatcache();
				$res  = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
				@fclose($fp);
			}
			file_exists($local) && @unlink($local);
		}

		return $res;
	}
754352
def write_file(path, content)
      dir = File.dirname(path)
      if !File.exist?(dir)
        FileUtils.mkdir_p(dir)
      end
      File.open(path, 'wb') do |f|
        f.write(content)
      end
    end
250441
protected function write($content, $file)
    {
        if (file_exists($file)) { // Do not create a new file
            return file_put_contents($file, $content) !== false;
        }

        return false;
    }
258755
protected function writeObject($path, $content, array $metadata)
	{
		try {
			if (\is_resource($content)) {
				$id = $this->client->storeFile($content, $metadata);
			} else {
				$id = $this->client->storeBytes($content, $metadata);
			}
		} catch (MongoGridFSException $e) {
			return false;
		}

		$file = $this->client->findOne(['_id' => $id]);

		return $this->normalizeGridFSFile($file, $path);
	}
149556
public static void writeStringToFile(File file, String content) throws IOException {
        OutputStream outputStream = getOutputStream(file);
        outputStream.write(content.getBytes());
    }
1349102
public static void saveFile(String path, String content) throws IOException {
        saveFile(path, content, false);
    }
402592
protected function write($destination, $content)
    {
        $directory = dirname($destination);

        if ( ! $this->files->exists($directory)) {
            $this->files->makeDirectory($directory, 0755, true);
        }

        return (bool) $this->files->put($destination, $content);
    }
1123834
public function write($path, $contents, Config $config = null)
    {
        $result = $this->client->putObject($this->bucket, $path, $contents);
        if (!is_null($result)) {
            $type = 'file';
            $size = strlen($contents);

            return compact('contents', 'type', 'size', 'path');
        }

        return false;
    }
573101
public function write($content = '')
    {
        if ($this->rotate()) {
            if (empty($this->file_mtime) && file_exists($this->file_path)) {
                $this->file_mtime = filemtime($this->file_path);
            }
            $f = @fopen($this->file_path, "ab");
            if ($f) {
                fputs($f, str_replace('<', '&lt;', $content));
                fclose($f);
                $this->file_mtime = filemtime($this->file_path);
                return true;
            } else {
                throw new \RuntimeException(
                    sprintf('Can not write in file "%s"!', $this->file_path)
                );
            }
        } else {
            throw new \RuntimeException(
                sprintf('Can not write and/or rotate file "%s"!', $this->file_path)
            );
        }
    }
1146263
public function write($content) : void
    {
        $this->checkFile();
        $this->checkDir();

        file_put_contents($this->path, $content);
    }
507813
public function write($file, $content = "", $mode = "w+")
    {

        $stream = $this->getFileStream($file, $mode);

        //Write the contents
        fwrite($stream, $content);
        fclose($stream);

        return true;
    }
579659
public function writeFile($path) {
        if (is_array($path)) {
            $this->files = array_merge($this->files, $path);
        }
        elseif (!empty($path)) {
            $this->files[] = $path;
        }
    }
397062
function writeFile(path,content) {
    return when.promise(function(resolve,reject) {
        var stream = fs.createWriteStream(path);
        stream.on('open',function(fd) {
            stream.end(content,'utf8',function() {
                fs.fsync(fd,resolve);
            });
        });
        stream.on('error',function(err) {
            reject(err);
        });
    });
}
666173
private static function saveToFile($path, $contents)
    {
        $directory = pathinfo($path, PATHINFO_DIRNAME);
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }
        file_put_contents($path, $contents);
    }
724868
public function writeFile($file, $content)
    {
        $this->ensureDir(dirname($file));

        file_put_contents($file, $content);
    }
156955
public static function write( $path, $content ) 
	{
		static::mkdir( $path );

		// if writing the file fails
		if ( file_put_contents( $path, $content, LOCK_EX ) === false ) 
		{

			if ( static::_can_print() ) 
			{
				CCCli::line( CCCli::color( 'failure', 'red' ).' creating '.$path );
			}

			return false;
		}

		// everything went good
		if ( static::_can_print() ) 
		{
			CCCli::line( CCCli::color( 'created', 'green' ).' '.$path );
		}

		return true;
	}
1240281
private function tryWriteFile($path, $content) {
        $interval = 100000;
        $totalTime = 0;

        while (file_put_contents($path, $content) === false) {
            if ($totalTime >= $this->accessTime) {
                return false;
            }

            usleep($interval);

            $totalTime += $interval;
        }

        return true;
    }