Save the file.

@throws \Exception On error

@return $this
979491
public function save()
    {
        if (!$this->original || empty($this->adapter)) {
            throw new \Exception('Original source is not defined');
        }

        call_user_func("{$this->adapter}::fixDestination", $this, $this->original);

        //Execute callbacks
        foreach ($this->callbacks as $name => $callback) {
            if ($callback) {
                if ($name === 'destination') {
                    $this->setDestination($callback($this));
                } else {
                    $this->options[$name] = $callback($this);
                }
            }
        }

        $destination = $this->getDestination(true);

        if (!$this->getOverwrite() && is_file($destination)) {
            throw new \RuntimeException(sprintf('Cannot override the file "%s"', $destination));
        }

        if ($this->getCreateDir() && !is_dir(dirname($destination))) {
            if (mkdir(dirname($destination), 0777, true) === false) {
                throw new \RuntimeException(sprintf('Unable to create the directory "%s"', dirname($destination)));
            }
        }

        call_user_func("{$this->adapter}::save", $this->original, $destination);

        return $this;
    }
213860
public function save()
    {
        if ( ! $this->isSaved()) {
            $this->write($this->data);
            $this->unsaved = false;
        }

        return $this;
    }
1363631
public function serve()
	{
		return self::serve_file($this->_filename, $this->_saveas, $this->_disposition, $this->_acceptranges);
	}
46898
public function save( $fileName = NULL )
	{
		if( empty( $fileName ) )
		{
			if( empty( $this->fileName ) )
				throw new Exception( 'No TAR file name for saving given' );
			$fileName = $this->fileName;
		}
		$this->generateTar();																		// Encode processed files into TAR file format
		return FS_File_Writer::save( $fileName, $this->content );										//  write archive file
	}
1155001
public function save() {
        try {
            $this->file->upload();

            $filename = $this->file->getNameWithExtension();

            if ($this->function) {
                $func = $this->function;
                $fileSource = $this->dest . '/' . $this->file->getNameWithExtension();
                $filename = $this->alternaiveName ? $this->alternaiveName . '.' . $this->file->getExtension() : $this->file->getNameWithExtension();

                $image = new ImageResize($fileSource);
                call_user_func_array(array($image, $func), $this->params);
                $image->save($this->dest . '/' . $filename);
            }
            return $filename;
        } catch (\Exception $e) {
            $this->errors = $e->getMessage();
            return false;
        }

        return true;
    }
428698
public function save()
    {
        $id = $this->getQuery()->saveById($this->id, $this->toArray());
        if (is_null($this->id)) {
            $this->id = $id;
        }
        return $this;
    }
788288
protected function save()
	{
		$xml     = new SimpleXMLElement('<storage/>');
		$content = $this->getContent();
		array_to_xml($content, $xml);
		$this->file->setContent($xml->asXML());
	}
719958
public function save()
    {
        if ($this->isNew()) {
            return $this->adapter->create($this);
        } else {
            return $this->adapter->update($this);
        }
    }
56286
private function open()
    {
        // Used for trapping `fopen()` errors.
        $this->trappedErrorNumber = null;
        $this->trappedErrorString = null;

        set_error_handler(
            function($errorNo, $errorString) {
                $this->trapError($errorNo, $errorString);
            }
        );

        $needsChmod = !file_exists($this->file);
        $file = fopen($this->file, 'a');

        restore_error_handler();

        // Handles trapped `fopen()` errors.
        if ($this->trappedErrorNumber) {
            throw new Exception(
                sprintf(
                    "Logger Error: '%s'",
                    $this->trappedErrorString
                ),
                $this->trappedErrorNumber
            );
        }

        if ($needsChmod) {
            @chmod($this->file, $this->mode & ~umask());
        }

        return $this->file = $file;
    }
771434
public function save()
	{
		$converter = $this->extracter->converter();
		$data = $converter->toNative($this->params);

		$this->fs->dumpFile($this->file, $data);
	}
716208
public function save()
    {
        if (true == file_exists($this->getFileName())) {
            unlink($this->getFileName());
        }
        touch($this->getFileName());
        $content = "";
        foreach ($this->getEnvironments() as $environment) {
            $content .= "{$environment}\n";
        }
        file_put_contents($this->getFileName(), $content);
        return $content;
    }
558010
public function send()
    {
        if ($this->sent === false) {
            $this->sendHeaders();
            $this->sendCookies();

            $content = (string)$this->getBody();
            if (!empty($content)) {
                echo $content;
            } else {
                if (is_string($this->file)) {
                    if (!file_exists($this->file)) {
                        throw new Exception('The requested file was not found');
                    }
                    $handle = fopen($this->file, 'r');

                    if ($handle !== false) {
                        fpassthru($handle);
                        fclose($handle);
                    }
                }
            }

            $this->sent = true;

            return $this;
        }

        throw new Exception('Response was already sent');
    }
450359
public function create()
    {
        //try to save all the fields we allow
        {
            if ($this->model->save($this->request->getPost(), $this->createFields)) {
                return $this->response($this->model->toArray());
            } else {
                //if not thorw exception
                throw new Exception($this->model->getMessages()[0]);
            }
        }
    }
351275
public function save()
    {
        $this->triggerEvent('onBeforeSave');

        $result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);

        $value = reset($result);
        $storageKey = key($result);
        if ($value && $storageKey) {
            $this->setStorageKey($storageKey);
            if (!$this->hasKey()) {
                $this->setKey($storageKey);
            }
        }

        if (method_exists($this, 'saveUpdatedMedia')) {
            $this->saveUpdatedMedia();
        }

        try {
            $this->getFlexDirectory()->clearCache();
            if (method_exists($this, 'clearMediaCache')) {
                $this->clearMediaCache();
            }
        } catch (InvalidArgumentException $e) {
            /** @var Debugger $debugger */
            $debugger = Grav::instance()['debugger'];
            $debugger->addException($e);

            // Caching failed, but we can ignore that for now.
        }

        $this->triggerEvent('onAfterSave');

        return $this;
    }
1314640
public function save()
    {
        if ($path = $this->getProjectPath()) {
            $path .= '/' . $this->getOutputFile();
            file_put_contents($path, serialize($this->getContainer()));
        } else {
            throw new \RuntimeException('No project path provided.');
        }
        return $this;
    }
1015747
public function Save () {
		$rawContent = $this->Dump();
		if ($rawContent === FALSE) 
			throw new \Exception('Configuration data was not possible to dump.');
		$app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance();
		$toolClass = $app->GetToolClass();
		try {
			$toolClass::SingleProcessWrite(
				$this->fullPath, 
				$rawContent, 
				'w',	// Open for writing only; place pointer at the beginning and truncate to zero length. If file doesn't exist, create it.
				10,		// Milliseconds to wait before next lock file existence is checked in `while()` cycle.
				5000,	// Maximum milliseconds time to wait before thrown an exception about not possible write.
				30000	// Maximum milliseconds time to consider lock file as operative or as old after some died process.
			);
		} catch (\Exception $ex) {
			throw $ex;
		}
		return TRUE;
	}
786075
public function save()
    {
        if ($this->isRoot()) return;
        
        if (isset($this->fields['alias']) && $this->fields['alias'] != $this->alias) {
            try {
                $c = $this->parent->getChildByAlias($this->fields['alias']);
            } catch (\Exception $e) {
                $c = false;
            }
            if ($c && $c->id != $this->id) throw new Exception\Form(Exception\CMS::CAT_EXISTS, 'alias', $this->fields['alias']);
            
            if ($this->parent->isRoot() && file_exists(DOCROOT.$this->fields['alias'])) 
                throw new Exception\Form(Exception\CMS::CAT_PHYSICAL_EXISTS, 'alias', $this->fields['alias']);
        }
        
        $conn = self::getDbConnection();
		
        $set = '';
        if (isset($this->fields['name'])) $set .= ', name='.$conn->quote($this->fields['name']);
        if (isset($this->fields['alias'])) $set .= ', tablename='.$conn->quote($this->fields['alias']);
        if (isset($this->fields['template'])) $set .= ', template='.$conn->quote($this->fields['template']);
        if (isset($this->fields['typ'])) $set .= ', typ='.(int)$this->fields['typ']; 
        if (isset($this->fields['hidden'])) $set .= ', hidden='.(int)$this->fields['hidden'];  

        $type = 'type';
        
        if (!$this->isLink()) {
        
            if (isset($this->fields['inheritFields'])) $set .= ', inheritFields='.(int)$this->fields['inheritFields'];         
        
            $set .= $this->saveDynamicFields();
            $this->saveDynimicLinks();
        
            if (isset($this->fields['autoalias'])) {
                if ($this->fields['autoalias'])
                    $type = '('.$type.')|'.Catalog::AUTOALIAS;
                    else $type = '('.$type.')&'.~Catalog::AUTOALIAS;
            }
            
            if (isset($this->fields['autoalias_type'])) {
				if ($this->fields['autoalias_type'] == 3) $type = '(('.$type.')|'.Catalog::AUTOALIAS_ID.')&'.~Catalog::AUTOALIAS_TRANSLIT;
                if ($this->fields['autoalias_type'] == 2) $type = '(('.$type.')|'.Catalog::AUTOALIAS_TRANSLIT.')&'.~Catalog::AUTOALIAS_ID;
                if ($this->fields['autoalias_type'] == 1) $type = '(('.$type.')&'.~Catalog::AUTOALIAS_TRANSLIT.')&'.~Catalog::AUTOALIAS_ID;
            }
            
            if (isset($this->fields['cat_inherit'])) {
                if ($this->fields['cat_inherit'])
                    $type = '('.$type.')|'.Catalog::INHERIT;
                    else $type = '('.$type.')&'.~Catalog::INHERIT;
            }	 
            
            if (isset($this->fields['typ']) && $this->materialsType != $this->fields['typ']) {
				$newtable = $conn->fetchColumn("SELECT alias from types where id=".$this->fields['typ']);
        		if ($newtable) {
        		    $r = $conn->query("select B.alias,A.name from types_fields A, types B where B.id=A.id and A.type=".FIELD_LINKSET." and A.pseudo_type<>".PSEUDO_FIELD_CATOLOGS." and A.len=".$this->id);
        		    while ($f = $r->fetch(\PDO::FETCH_NUM))
        		        $conn->executeQuery("alter table ".$f[0]."_".$this->materialsTable."_".$f[1]." rename ".$f[0]."_".$newtable."_".$f[1]);   
        		}
            }
        }

        $conn->executeQuery("UPDATE dir_data SET type=$type $set where id=".$this->id);

        $this->updateCache();

    }