Write in JS routing file
@param string $file_contains File contains
@return int Operation is a success
345590
private function write(string $file_contains):int
    {
         $header = "/*\n * This is an iumio Framework component\n *\n * (c) RAFINA DANY <dany.rafina@iumio.com>";
         $headersub = "\n *\n * iumio Framework, an iumio component [https://iumio.com]\n *\n";
         $headersub2 = " * To get more information about licence, please check the licence file\n */";
         $date = new \DateTime();
         $date = $date->format('Y-m-d H:i:s');
         $header2 = "\n\n/* File generate by Mercure Routing - Time : $date. DO NOT OVERRIDE IT ! */\n\n";

        $rs = $header.$headersub.$headersub2.$header2."var mercuredata = ".$file_contains.";";
        return (($this->is_base)? JL::put($this->mercure_path_base, $rs) : JL::put($this->mercure_path, $rs));
    }
983314
public function writeFile()
    {
        if (!empty($this->fileName)) {
            if (!file_exists($this->destinationPath)) {
                mkdir($this->destinationPath, 0777);
            }
            $file = $this->file();
            $fileHandle = fopen($file, 'w+');
            fwrite($fileHandle, $this->body);
            fclose($fileHandle);
            return $file;
        } else {
            return FALSE;
        }
    }
1349855
public static function checkFile($file)
    {
        if (Symphony::Log()) {
            Symphony::Log()->pushDeprecateWarningToLog('General::checkFile()', '`General::checkFileWritable()');
        }
        clearstatcache();
        $dir = dirname($file);

        if (
            (!is_writable($dir) || !is_readable($dir)) // Folder
            || (file_exists($file) && (!is_readable($file) || !is_writable($file))) // File
        ) {
            return false;
        }

        return true;
    }
338575
public function is_external_file( $file_url ) {

        // Set default return value.
        $is_external_file = false;

        // Parse url.
        $parsed_file_url = parse_url( $file_url );

        // Parse site url.
        $parsed_site_url = parse_url( site_url() );

        // Check if hosts don't match.
        if ( $parsed_file_url[ 'host' ] !== $parsed_site_url[ 'host' ] ) {

            // We now know the file is externally hosted.
            $is_external_file = true;

        }

        return $is_external_file;

    }
615511
public function addJS($file,$src='',$priority=100){
		if(!isset($this->controller)){
			return false;
			}
		$this->controller->js[]=array('file'=>$file,'src'=>$src,'priority'=>$priority);
		return true;
		}
453084
private function logWriteFile()
    {
        $cfg = $this->form->cfg;
        $file = $cfg['logFile'];
        $keys = \array_column($this->columns, 'key');
        $values = \array_column($this->columns, 'values');
        $appendFile = false;
        $keyCounts = array();       // for indexing keys of same name
        foreach ($keys as $k => $key) {
            $key = \trim(\strtolower($key));
            if (!isset($keyCounts[$key])) {
                $keyCounts[$key] = 1;
            } else {
                $keyCounts[$key]++;
                $key .= ' '.$keyCounts[$key];
            }
            $keys[$k] = $key;
        }
        if (\file_exists($file)) {
            $this->debug->log('log exists');
            // check that the keys in file match the data we're writing
            $handle = \fopen($file, 'rb');
            $keysExisting = \fgetcsv($handle, 4096, $cfg['logDelimitter']);
            \fclose($handle);
            if ($keysExisting === $keys) {
                $appendFile = true;
            }
        } else {
            $this->debug->log($file.' does not exist');
        }
        if ($appendFile) {
            $appendString = ArrayUtil::implodeDelim($values, $cfg['logDelimitter']);
            $return = FileIo::safeFileAppend($file, $appendString);
        } else {
            $rows = FileIo::readDelimFile($file);
            $rows[] = \array_combine($keys, $values);
            $return = FileIo::writeDelimFile($file, $rows, array(
                'char' => $cfg['log_delimitter']
            ));
        }
        return $return;
    }
1319469
private function _view_file_exists()
    {
        $route = Rails::application()->dispatcher()->router()->route();
        /**
         * Build a simple path for the view file, as there's no support for
         * stuff like modules.
         * Note that the extension is PHP, there's no support for different
         * request formats.
         */
        $base_path = Rails::config()->paths->views;
        $view_path = $base_path . '/' . $route->path() . '.php';
        return is_file($view_path);
    }
1038517
public static function write($file = false, $content = false) {

        if ($file && $content) {

            if (file_put_contents($file, $content)) {

                return true;
            }
        }

        return false;
    }
1306556
public static function write($file, &$buffer, $use_streams = false)
	{
		@set_time_limit(ini_get('max_execution_time'));

		// If the destination directory doesn't exist we need to create it
		if (!file_exists(dirname($file)))
		{
			Folder::create(dirname($file));
		}

		if ($use_streams)
		{
			$stream = Stream::getStream();

			// Beef up the chunk size to a meg
			$stream->set('chunksize', (1024 * 1024));

			if (!$stream->writeFile($file, $buffer))
			{
				Log::add(sprintf('%1$s(%2$s): %3$s', __METHOD__, $file, $stream->getError()), Log::WARNING, 'jerror');

				return false;
			}

			return true;
		}
		else
		{
			$file = Path::clean($file);
			$ret = is_int(file_put_contents($file, $buffer)) ? true : false;

			return $ret;
		}
	}
714974
public function putContents( $contents, $ex_lock = false ) : int
    {
        $flags = $ex_lock ? LOCK_EX : 0;
        $res = file_put_contents( $this->path, $contents, $flags );
        if ($res === FALSE){
            throw new FileOutputException($this);
        }
        return $res;
    }
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;
    }
194521
public function write($file_name, $content = '')
    {
        if (!is_file($file_name)) {
            return false;
        }

        return file_put_contents($file_name, $content, LOCK_EX);
    }
657236
function writeFile(file, contents) {
	return new Promise(
		(resolve, reject) => {
			fs.writeFile(
				file, contents, error => {
					if (error) {
						reject(error);
					} else {
						// console.log('writeFile', [file, contents]);
						resolve(contents);
					}
				}
			)
		}
	);
}
447199
static function sendFile($file_path,$display_name = null){
        if($display_name ===null){
            $display_name = basename($file_path);
        }
        header('Content-Description: File Transfer');
        header('Content-Disposition: attachment; filename='.urlencode($display_name));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Content-Length: '.filesize($file_path));
        readfile($file_path);
    }
258208
public function file_contains_php($file)
    {
        $contents = file_get_contents($file);
        $position = strpos($contents, '<?php');
        return $position !== false;
    }
106477
public static function write(string $file = '', string $data = '', bool $doAppend = false): bool
    {
        $result = false;
        $file = static::normalizePath($file);
        if (static::verifyPath($file) && Directory::create(\dirname($file))) {
            $flags = $doAppend ? FILE_APPEND : 0;
            $flags |= static::$writeLocks ? LOCK_EX : 0;

            $result = @\file_put_contents($file, $data, $flags) !== false;
            @\chmod($file, static::$newFileMode);
        }
        return $result;
    }
1339034
public function delete($file_id)
    {
        if (empty($file_id)) {
            return false;
        }

        $deleted = $count = 0;
        foreach ((array) $this->file->getList(array('file_id' => $file_id)) as $file) {
            $deleted += (int) $this->file->delete($file['file_id']);
            $count++;
        }

        return $count && $count == $deleted;
    }