Save file to location

@param string $path
@param int    $format Support XML, HTML, and JSON
@throws \Inphinit\Experimental\Exception
@return void
514919
public function save($path, $format = Document::XML)
    {
        switch ($format) {
            case Document::XML:
                $format = 'saveXML';
                break;
            case Document::HTML:
                $format = 'saveHTML';
                break;
            case Document::JSON:
                $format = 'toJson';
                break;
            default:
                throw new DomException('Invalid format', 2);
        }

        $tmp = Storage::temp($this->$format(), 'tmp', '~xml-');

        if ($tmp === false) {
            throw new DomException('Can\'t create tmp file', 2);
        } elseif (copy($tmp, $path) === false) {
            throw new DomException('Can\'t copy tmp file to ' . $path, 2);
        } else {
            unlink($tmp);
        }
    }
1032891
public function setFormat($format)
    {
        $this->request->setFormat($format);
        $this->baseRenderingContext->getTemplatePaths()->setFormat($format);
    }
145184
function write($text,$format='r') {
		$fw=Base::instance();
		$fw->write(
			$this->file,
			date($format).
				(isset($_SERVER['REMOTE_ADDR'])?
					(' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '.
			trim($text).PHP_EOL,
			TRUE
		);
	}
749002
public function save($path = self::DEFAULT_FILENAME)
	{
		$file = new File($path);

		$file->write(json_encode($this->data));

		return $this;
	}
205736
public static function setStringFormat(string $format)
    {
        switch ($format) {
            case 'raw':
                self::$format = 'raw';
                break;
            case 'basic':
                self::$format = 'basic';
                break;
            case 'full':
            default:
                self::$format = 'full';
                break;
        }
    }
298997
def _save_to(self, im, path, format=None):
        
        format = format or im.format
        if not format:
            _, format = splitext(path)
            format = format[1:]
        im.format = format.lower()
        im.save(filename=path)
180525
public function useBoilerplate($path, $format = null)
    {
        $this->boilerplatePath = $path;
        $this->boilerplateFormat = $format;
        return $this;
    }
357310
public function publishNode($path, $format = 'php', $node = null)
    {
        if ($this->files->isDirectory($path)) {
            foreach (['config', 'hooks', 'paths', 'remote', 'vcs', 'stages', 'strategies', 'plugins'] as $file) {
                $this->publishNode($path.'/'.$file.'.'.$format, $format, $file);
            }

            return;
        }

        // If a single file was passed, infer format from extension
        $format = $format ?: pathinfo($path, PATHINFO_EXTENSION);
        $configuration = $this->getDefinition($format, $node);

        $this->files->put($path, $configuration);
    }
1089793
def write_file(path, data, format=True):
    
    if format:
        fs.write_file(path, format_json(data))
    else:
        fs.write_file(path, json.dumps(data))
725008
public function save(string $format, ?string $output)
    {
        switch ($format) {
            case self::FORMAT_PUML:
                $content = $this->generatePuml();
                break;
            case self::FORMAT_EPS:
            case self::FORMAT_PNG:
            case self::FORMAT_SVG:
                $content = $this->generateImage($format);
                break;
            default:
                throw new DiagramException(sprintf('Format "%s" not handled.', $format));
                break;
        }
        $output = $this->validateOutputLocation($format, $output);

        return file_put_contents($output, $content);
    }
249707
public function save($path, $content)
    {
        $path = $this->getRealPath($path);
        if (!is_dir(dirname($path))) {
            @mkdir(dirname($path), 0755, true);
        }
        
        return file_put_contents($path, $content);
    }
650960
public function save($save_path = null, $make_paths = false)
	{
		$path = $this->source;

		if (!is_null($save_path))
		{
			$info = pathinfo($save_path);

			if ($make_paths)
			{
				\App::get('filesystem')->makeDirectory($info['dirname']);
			}

			if (!is_dir($info['dirname']) && $make_paths == false)
			{
				$this->setError(\Lang::txt('You must supply a valid path or allow save function to create recursive path'));
				return;
			}

			$path = $save_path;
		}

		$this->output($path);
	}
395825
public function saveConfiguration($settings)
    {
        if (file_exists($this->path) && !is_writable($this->path)) {
            throw new Exception('The file "' . $this->path . '" isn\'t writable!');
        }
        
        $content = json_encode($settings);
        
        return file_put_contents($this->path, $content);
    }
497296
public static function save( $filePath, $value, $format = FALSE )
	{
		$writer	= new FS_File_JSON_Writer( $filePath );
		return $writer->write( $value, $format );
	}
1343318
public function write( $path, $content )
	{
		try {
			$this->fs->put( $path, $content );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
438412
public function upload($file, $format = 'json')
	{
		// Is this "file" a URL?
		$url = filter_var($file, FILTER_VALIDATE_URL) !== false;

		$data = array(
			'key' => $this->key,
			'format' => $format
		);

		if ($url) {
			$data['url'] = $file;
		} else {
			$data['fileupload'] = $file;
		}

		if ($this->credentials) {
			$data['a_username'] = $this->credentials['username'];
			$data['a_password'] = $this->credentials['password'];
		} else if($this->cookie) {
			$data['cookie'] = $this->cookie;
		}

		return $this->post('https://post.imageshack.us/upload_api.php', $data);
	}
426341
public function saveReport($path){
        if (!isset($this->rawreport)){
            return false;
        }
        try{
            file_put_contents($path, $this->rawreport);
            $this->log("Successfully saved report #".$this->options['ReportId']." at $path");
        } catch (Exception $e){
            $this->log("Unable to save report #".$this->options['ReportId']." at $path: $e",'Urgent');
            return false;
        }
    }