Writes content in a file.
@since 0.9.0
@since 0.9.3 Fixes undefined constant FS_CHMOD_FILE.

@global $wp_filesytem

@param string $filename File name.
@param mixed  $content  File content.
486210
public function write( $filename, $content )
    {
        if (!$this->authenticated) return false;
        global $wp_filesystem;
        return $wp_filesystem->put_contents(
            $filename,
            $content,
            defined( FS_CHMOD_FILE ) ? FS_CHMOD_FILE : ( 0644 & ~ umask() )
        );
    }
399123
public static function write($path, $content)
    {
        if (file_exists($path) && is_file($path) && !is_writable($path)) {
            return new PermissionDeniedException("$path is not writable");
        }

        $directory = dirname($path);

        if (!is_writable($directory)) {
            return new PermissionDeniedException("$directory is not writable");
        }

        file_put_contents($path, $content);
    }
203370
protected function writeConfigFile($content)
    {
        if (!is_writable('config/autoload')) {
            return false;
        }

        $file = 'config/autoload/yawik.config.global.php';
        // need to chmod 777 to be usable by docker and local environment
        @touch($file);
        @chmod($file, 0777);
        return (bool) @file_put_contents($file, $content, LOCK_EX);
    }
687006
public function dumpFile($filename, $content)
    {
        $dir = dirname($filename);

        if (!is_dir($dir)) {
            $this->mkdir($dir);
        }

        if (!is_writable($dir)) {
            throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
        }

        // Will create a temp file with 0600 access rights
        // when the filesystem supports chmod.
        $tmpFile = $this->tempnam($dir, basename($filename));

        if (false === @file_put_contents($tmpFile, $content)) {
            throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
        }

        @chmod($tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());

        $this->rename($tmpFile, $filename, true);
    }
1064413
def write_file(self, filename, content):
        
        with open(filename, 'wb') as f:
            self.log.debug(content)
            f.write(content)
64170
public void write(String filename, String content) throws IOException {
    FSDataOutputStream s = getMfs().create(new Path(filename));
    s.writeBytes(content);
    s.close();
  }
816556
public function writeFile(
        string $content,
        string $filename,
        string $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING,
        ?ErrorCorrectionLevel $ecLevel = null
    ) : void {
        file_put_contents($filename, $this->writeString($content, $encoding, $ecLevel));
    }
626978
public function write($filename)
    {
        if (count($this) == 0) return;
        $file = fopen($filename, 'w');
        fwrite($file, $this->toJson());
        fclose($file);
        unset($file);
    }
1170729
public function save($file, $content)
    {
        $dir = dirname($file);

        if (!is_dir($dir)) {
            mkdir($dir, 0777);
        }

        if (file_put_contents($file, $content)) {
            chmod($file, 0777);

            return true;
        } else {
            $message = "Cannot open cache file for writing: ";
            //			if (!Nip_Staging::instance()->isPublic()) {
            //				$message .= " [ ".$this->cache_file." ] ";
            //			}
            die($message);
        }
    }
776425
protected static function setFile($content)
    {
        $root = Process::root;

        if (file_exists(Process::root.'config/alias.php')) {
            $file = fopen(Process::root.'config/alias.php', 'w');
            fwrite($file, $content);
            fclose($file);
            //
            return true;
        }

        return false;
    }
933424
private function saveContent($file, $content)
    {
        if (file_put_contents($file, $content, LOCK_EX) === false) {
            throw new RuntimeException('Plugin Manager is not able to save ' . $file . '.'); // @codeCoverageIgnore
        }
    }
883541
protected function writeToCache($fileName, $content)
    {
        if ($this->cachePath === null || !is_dir($this->cachePath) || !is_writable($this->cachePath)) {
            return;
        }
        $encoder    = new \Riimu\Kit\PHPEncoder\PHPEncoder();
        $contentPHP = $encoder->encode($content, [
            'whitespace' => false,
            'recursion.detect' => false
        ]);
        $cache      = '<?php $crudlexCacheContent = '.$contentPHP.';';
        file_put_contents($this->getCacheFile($fileName), $cache);
    }
1028445
public function save($filename, $content)
    {
        $this->logs[] = $content;
        $this->storage->save($filename, $content);

        return $this;
    }
1130038
public static function write(string $file, $content, int $mode = 0666): void
	{
		NetteFileSystem::write($file, $content, $mode);
	}
601566
public static function touch($filename, $content = '')
    {
        self::mkdir(dirname($filename));
        file_put_contents($filename, $content);
    }
762478
static function writeFile( $filename,  $fileContent,  $flags=null){
        mkdir(dirname($filename), 0777, true);
        file_put_contents($filename,$fileContent,$flags);
    }
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 );
	}