Sets the temporary file to use when content of found documents should be streamed directly into a temporary file.

@param string $tmp_file The TMP-file to use.
779226
public function setTmpFile($tmp_file)
  {
    //Check if writable
    $fp = @fopen($tmp_file, "w");
    
    if (!$fp)
    {
      return false;
    }
    else
    {
      fclose($fp);
      $this->tmpFile = $tmp_file;
      return true;
    }
  }
757039
protected function set_temp_file_path() {
        global $USER, $CFG;
        make_temp_directory('csvimport/' . $USER->id);
        $path = $CFG->tempdir . '/csvimport/' . $USER->id. '/' . $this->filename;
        // Check to see if the file exists, if so delete it.
        if (file_exists($path)) {
            unlink($path);
        }
        $this->path = $path;
    }
88234
public function setTmpPath($tmpPath = '')
    {
        if (empty($tmpPath)) {
            $tmpPath = __DIR__ . '/../storage/tmp/';
        }
        $this->tmpPath = $tmpPath;

        return $this;
    }
374198
protected function configure() {
		parent::configure();

		if (($tmp = $this->options['tmpPath'])) {
			if (!file_exists($tmp)) {
				if (@mkdir($tmp)) {
					@chmod($tmp, $this->options['tmbPathMode']);
				}
			}
			
			$this->tmpPath = is_dir($tmp) && is_writable($tmp) ? $tmp : false;
		}
		
		if (!$this->tmpPath && $this->tmbPath && $this->tmbPathWritable) {
			$this->tmpPath = $this->tmbPath;
		}

		$this->mimeDetect = 'internal';
	}
508133
def _CopyFileObjectToTemporaryFile(self, file_object, temporary_file):
    
    file_object.seek(0, os.SEEK_SET)
    data = file_object.read(self._READ_BUFFER_SIZE)
    while data:
      temporary_file.write(data)
      data = file_object.read(self._READ_BUFFER_SIZE)
508648
protected function assertTmpFile()
    {
        if (empty($this->tmpName)) {
            throw new \RuntimeException("There is no tmp_file for " . $this->getDesc()
                . ": " . $this->getErrorDescription());
        }
        
        if (!file_exists($this->tmpName)) {
            throw new \RuntimeException("The " . $this->getDesc() . " no longer exists or is already moved");
        }
        
        if ($this->assertIsUploadedFile && !$this->isUploadedFile($this->tmpName)) {
            throw new \RuntimeException("The specified tmp_name for " . $this->getDesc() . " doesn't appear"
                . " to be uploaded via HTTP POST");
        }
    }
1362165
public function setCache() {
        if (!file_exists($this->_fileName)) {
            file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
        }

        $timeAgo = time() - filemtime($this->_fileName);

        if ($timeAgo > $this->_time) {
            file_put_contents($this->_fileName, $this->_compress(serialize($this->_content)));
        }
    }
206107
public function load($file)
    {
        $this->temporaryFileManager->enterModule('Templating');
        $this->temporaryFileManager->load($file . '.php');
        $this->temporaryFileManager->exitModule();
    }
821962
private function setFile($name)
    {
        $this->fileName = $name . '.';
        $this->file     = $this->getConfig('tpl_folder') . str_replace('.', '/', $name) . $this->getConfig('tpl_file_format', '.pytotpl.php');
    }
930428
def tmp_file(*args, **kwargs):
    
    fileno, path = tempfile.mkstemp(*args, **kwargs)

    # create the file
    with open(path, "w") as f:
        f.write("")

    # yield it
    try:
        yield fileno, path
    finally:
        if os.path.exists(path):
            os.remove(path)
768962
public function deleteTemporaryFiles()
    {
        $this->progress('--- Delete temporary files');

        $this->config->get('deletable')->each(function ($directory) {
            if (file_exists($directory = $this->dataDir($directory))) {
                $this->deleteDirectory($directory);
            }
        });
    }
300899
protected function saveTemporaryFile($tmpFile, &$error = null)
    {
        // Determine container object
        $error = null;
        $fileObject = null;

        if (empty($tmpFile)) {
            $error = _t('SilverStripe\\Forms\\FileUploadReceiver.FIELDNOTSET', 'File information not found');
            return null;
        }

        if ($tmpFile['error']) {
            $this->getUpload()->validate($tmpFile);
            $error = implode(' ' . PHP_EOL, $this->getUpload()->getErrors());
            return null;
        }

        // Search for relations that can hold the uploaded files, but don't fallback
        // to default if there is no automatic relation
        if ($relationClass = $this->getRelationAutosetClass(null)) {
            // Allow File to be subclassed
            if ($relationClass === File::class && isset($tmpFile['name'])) {
                $relationClass = File::get_class_for_file_extension(
                    File::get_file_extension($tmpFile['name'])
                );
            }
            // Create new object explicitly. Otherwise rely on Upload::load to choose the class.
            $fileObject = Injector::inst()->create($relationClass);
            if (! ($fileObject instanceof DataObject) || !($fileObject instanceof AssetContainer)) {
                throw new InvalidArgumentException("Invalid asset container $relationClass");
            }
        }

        // Get the uploaded file into a new file object.
        try {
            $this->getUpload()->loadIntoFile($tmpFile, $fileObject, $this->getFolderName());
        } catch (Exception $e) {
            // we shouldn't get an error here, but just in case
            $error = $e->getMessage();
            return null;
        }

        // Check if upload field has an error
        if ($this->getUpload()->isError()) {
            $error = implode(' ' . PHP_EOL, $this->getUpload()->getErrors());
            return null;
        }

        // return file
        return $this->getUpload()->getFile();
    }
371163
private function rollbackOpeningFile($temp_file = null)
    {
        flock($this->getFile(), LOCK_UN);
        fclose($this->getFile());
        if(is_resource($temp_file))
        {
            fclose($temp_file);
            unlink($this->getTempFilePath());
        }
    }
334780
public function setFilePointer($pointer)
	{
		if(!is_resource($pointer))
			throw new InvalidArgumentException("Invalid type - not a file resource");
		
		$this->pointer = $pointer;
		
		# and now to set everything up...
		$metadata = stream_get_meta_data($this->pointer);
		
		# can this stream be read from?
		if(isset($metadata["mode"]))
		{
			$mode = rtrim($metadata["mode"], "bt");
			
			$super = (boolean) preg_match("/\+$/", $mode);
			$mode = rtrim($mode, "+");
			
			switch($mode)
			{
				case "r":
					$this->is_readable = true;
				break;
				
				case "w":
				case "a":
				case "x":
				case "c":
					$this->is_readable = $super;
				break;
				
				default:
					throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
				break;
			}
		}
		
		# can this stream be written to?
		if(isset($metadata["mode"]))
		{
			$mode = rtrim($metadata["mode"], "bt");
			
			$super = (boolean) preg_match("/\+$/", $mode);
			$mode = rtrim($mode, "+");
			
			switch($mode)
			{
				case "r":
					$this->is_writable = $super;
				break;
				
				case "w":
				case "a":
				case "x":
				case "c":
					$this->is_writable = true;
				break;
				
				default:
					throw new LogicException("Invalid file access type: '".$metadata["mode"]."'");
				break;
			}
		}
		
		# does this stream support seek functionality?
		if(isset($metadata["seekable"]))
			$this->is_seekable = (boolean) $metadata["seekable"];
		
		return null;
	}
427758
public function save($file, $compiled)
    {
        $this->temporaryFileManager->enterModule('Templating');

        $this->temporaryFileManager->save($file . '.php', $compiled);
        $this->temporaryFileManager->exitModule();
    }
913677
public function copyTempToAdapter($tempPath, AdapterFileInterface $file)
    {
        $this->filesystem->write($file->getPath(), file_get_contents($tempPath));

    }
285804
public static function tempfile($prefix)
    {
        global $settings;
        $folder = '/tmp';
        if (isset($settings['temporary_folder'])) {
            $folder = $settings['temporary_folder'];
        }
        return tempnam($folder, $prefix);
    }