Append the temp filename extension to $sFile

@param string $sFile Original file name
@return string $sFile with the temp extension appended

@throws Exception if the resulting filename exceeds the maximum filename length
164207
protected function appendTempExtension($sFile)
	{
		if($this->sTempFileExtension === '')
			throw new Exception("Programmer error: Empty temp file extension");

		$sFile .= $this->sTempFileExtension;

		$len = strlen($sFile);
		if($len > $this->nMaxFilenameLength)
			throw new Exception("Max filename length (".$this->nMaxFilenameLength.") exceeded: ".$sFile);

		return $sFile;
	}
202824
public function makeValidFileName($sFilename)
    {
        $sFilename = preg_replace('/[\s]+/', '_', $sFilename);
        $sFilename = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $sFilename);

        return str_replace(' ', '_', $sFilename);
    }
197783
public function getConfigByFilename(string $filename)
    {
        if (!isset($this->config[$filename])) {
            throw new Exception(
                'The file '.$filename.' has not been found',
                $this::ERR_FILE_NOT_FOUND
            );
        }
        
        return $this->config[$filename];
    }
782298
def create_temp_file(self, suffix, content):
        
        temp = tempfile.NamedTemporaryFile(suffix=suffix)
        temp.write(content.encode('latin1').decode('unicode_escape').encode('utf-8'))
        temp.seek(0) # Resets the temp file line to 0
        return temp
961665
public function setBuildFile($buildFile)
    {
        if (!file_exists($this->getDirectory() . $buildFile)) {
            throw new \Exception(Lang::get('build_file_missing'));
        }

        $this->buildFile = $buildFile;
    }
273931
public static function setConfig($sFile)
	{
		self::$_aTranslator = json_decode(file_get_contents($sFile));
		self::$_bConfigurated = true;
	}
559546
public static function writeFile($strFilePath, $strContents)
    {
        $fileHandle = fopen($strFilePath, "w");
        if (!$fileHandle) {
            throw new \Exception("Cannot open file for writing: " . $strFilePath);
        }

        if (fwrite($fileHandle, $strContents, strlen($strContents)) === false) {
            throw new \Exception("Unable to write file: " . $strFilePath);
        }
        fclose($fileHandle);
    }
943599
public static Resource getTempFile(String extension, boolean touch) throws IOException {
	String filename = CreateUniqueId.invoke();
	if (!StringUtil.isEmpty(extension, true)) {
	    if (extension.startsWith(".")) filename += extension;
	    else filename += "." + extension;
	}
	Resource file = getTempDirectory().getRealResource(filename);
	if (touch) ResourceUtil.touch(file);
	return file;
    }
105125
protected function moveTemporaryFile($strFile, $strDestination)
    {
        if (!is_file(TL_ROOT . '/' . $strFile)) {
            return '';
        }

        // Do not store the file
        if (!$this->arrConfiguration['storeFile']) {
            return $strFile;
        }

        // The file is not temporary
        if (stripos($strFile, $this->strTemporaryPath) === false) {
            return $strFile;
        }

        $strNew = $strDestination . '/' . basename($strFile);

        // Do not overwrite existing files
        if ($this->arrConfiguration['doNotOverwrite']) {
            $strNew = $strDestination . '/' . $this->getFileName(basename($strFile), $strDestination);
        }

        $blnRename = \Files::getInstance()->rename($strFile, $strNew);

        \Files::getInstance()->chmod($strNew, \Config::get('defaultFileChmod'));

        // Add the file to Dbafs
        if ($this->arrConfiguration['addToDbafs'] && $blnRename) {
            $objModel = \Dbafs::addResource($strNew);

            if ($objModel !== null) {
                $strNew = $objModel->uuid;
            }
        }

        return $strNew;
    }
877780
private function save($fileName, $filePath, $extension)
    {
        $fullPath = rtrim($filePath, '/').DIRECTORY_SEPARATOR.$fileName.$extension;

        $template = $this->renderTemplate($fullPath);

        $tempExecutable = tmpfile();
        fwrite($tempExecutable, $template);
        $tempFileName = stream_get_meta_data($tempExecutable)['uri'];
        $cmd = escapeshellcmd("{$this->binPath} --ssl-protocol=any --ignore-ssl-errors=true ".$tempFileName);
        shell_exec($cmd);
        fclose($tempExecutable);

        if (!file_exists($fullPath))
        {
            throw new TimeoutException('Page load timeout.');
        }

        return $fullPath;
    }
785892
public static function config($configFile = null)
    {
        if (!$configFile && self::$config) {
            return self::$config;
        }

        if (self::$config && self::$lock) {
            return self::$config;
        }

        if ($configFile === null) {
            $configFile = getcwd() . DIRECTORY_SEPARATOR . 'codeception.yml';
        }

        if (is_dir($configFile)) {
            $configFile = $configFile . DIRECTORY_SEPARATOR . 'codeception.yml';
        }

        $dir = realpath(dirname($configFile));
        self::$dir = $dir;

        $configDistFile = $dir . DIRECTORY_SEPARATOR . 'codeception.dist.yml';

        if (!(file_exists($configDistFile) || file_exists($configFile))) {
            throw new ConfigurationException("Configuration file could not be found.\nRun `bootstrap` to initialize Codeception.", 404);
        }

        // Preload config to retrieve params such that they are applied to codeception config file below
        $tempConfig = self::$defaultConfig;

        $distConfigContents = "";
        if (file_exists($configDistFile)) {
            $distConfigContents = file_get_contents($configDistFile);
            $tempConfig = self::mergeConfigs($tempConfig, self::getConfFromContents($distConfigContents, $configDistFile));
        }

        $configContents = "";
        if (file_exists($configFile)) {
            $configContents = file_get_contents($configFile);
            $tempConfig = self::mergeConfigs($tempConfig, self::getConfFromContents($configContents, $configFile));
        }
        self::prepareParams($tempConfig);

        // load config using params
        $config = self::mergeConfigs(self::$defaultConfig, self::getConfFromContents($distConfigContents, $configDistFile));
        $config = self::mergeConfigs($config, self::getConfFromContents($configContents, $configFile));

        if ($config == self::$defaultConfig) {
            throw new ConfigurationException("Configuration file is invalid");
        }

        // we check for the "extends" key in the yml file
        if (isset($config['extends'])) {
            // and now we search for the file
            $presetFilePath = codecept_absolute_path($config['extends']);
            if (file_exists($presetFilePath)) {
                // and merge it with our configuration file
                $config = self::mergeConfigs(self::getConfFromFile($presetFilePath), $config);
            }
        }

        self::$config = $config;

        // compatibility with suites created by Codeception < 2.3.0
        if (!isset($config['paths']['output']) and isset($config['paths']['log'])) {
            $config['paths']['output'] = $config['paths']['log'];
        }

        if (isset(self::$config['actor'])) {
            self::$config['actor_suffix'] = self::$config['actor']; // old compatibility
        }

        if (!isset($config['paths']['support']) and isset($config['paths']['helpers'])) {
            $config['paths']['support'] = $config['paths']['helpers'];
        }

        if (!isset($config['paths']['output'])) {
            throw new ConfigurationException('Output path is not defined by key "paths: output"');
        }

        self::$outputDir = $config['paths']['output'];

        // fill up includes with wildcard expansions
        $config['include'] = self::expandWildcardedIncludes($config['include']);

        // config without tests, for inclusion of other configs
        if (count($config['include'])) {
            self::$config = $config;
            if (!isset($config['paths']['tests'])) {
                 return $config;
            }
        }

        if (!isset($config['paths']['tests'])) {
            throw new ConfigurationException(
                'Tests directory is not defined in Codeception config by key "paths: tests:"'
            );
        }

        if (!isset($config['paths']['data'])) {
            throw new ConfigurationException('Data path is not defined Codeception config by key "paths: data"');
        }

        if (!isset($config['paths']['support'])) {
            throw new ConfigurationException('Helpers path is not defined by key "paths: support"');
        }

        self::$dataDir = $config['paths']['data'];
        self::$supportDir = $config['paths']['support'];
        self::$testsDir = $config['paths']['tests'];

        if (isset($config['paths']['envs'])) {
            self::$envsDir = $config['paths']['envs'];
        }

        Autoload::addNamespace(self::$config['namespace'], self::supportDir());
        self::loadBootstrap($config['settings']['bootstrap']);
        self::loadSuites();

        return $config;
    }
278201
private static File createTempFile() throws IOException
  {
    File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
    file.deleteOnExit();
    return file;
  }
152426
protected function appendMessageToFile($fileFullname, $messages)
    {
        $content = $this->getFileContent($fileFullname);
        $index = $this->getCursorPosition($content);
        $baseFile = basename($fileFullname);

        if ($index === false) {
            throw new Exception('Could not find a position in the [' . $baseFile . '] file to insert the messages.');
        }

        $newContent = substr_replace($content, PHP_EOL . $messages, $index + 1, 1);

        $this->putContentInFile($fileFullname, $newContent)
            ->info('New messages were added to the [' . $baseFile . '] file');
    }
732343
private void createTempFile() throws IOException {
        _tempfilef = File.createTempFile("org.browsermob.proxy.jetty.util.TempByteHolder-",".tmp",_temp_directory).getCanonicalFile();
        _tempfilef.deleteOnExit();
        _tempfile = new RandomAccessFile(_tempfilef,"rw");
    }
615915
public function encryptFile($strFile)
    {
        if (file_exists($strFile)) {
            $strData = file_get_contents($strFile);

            return $this->encrypt($strData);
        } else {
            throw new Caller('File does not exist: ' . $strFile);
        }
    }
1126371
public function getFileContents($sFile)
    {
        $sContents = null;
        if (file_exists($sFile) && is_readable($sFile)) {
            $sContents = file_get_contents($sFile);
        }

        return $sContents;
    }
455405
protected static function _prepareWriteFile($sFile) {

		$aConfig = Config::get('log');

		$sSpaceCheck = $sFile;

		if (file_exists($sFile)) {
			if (!is_writable($sFile)) {
				return FALSE;
			}
			if (filesize($sFile) > $aConfig['max_size']) {
				return self::$_bEnable = FALSE;
			}
		} else {
			$sSpaceCheck = dirname($sFile);
		}

		if (($iSpace = disk_free_space($sSpaceCheck)) < $aConfig['disk_free_space']) {
			// throw new Exception('not enough free disk space ' . $iSpace . '/' . $aConfig['disk_free_space']);
			return self::$_bEnable = FALSE;
		}

		return TRUE;
	}