Applies the given extension to the given file name if it is not already present.

@param string $name Filename to process.
@param string $ext Required file extension.

@return string
356896
protected function ext($name, $ext)
    {
        // Obtain Info:
        
        $info = pathinfo($name);
        
        // Check Extension:
        
        if (!isset($info['extension']) || $info['extension'] !== $ext) {
            $name = sprintf('%s.%s', $name, $ext);
        }
        
        // Answer Name:
        
        return $name;
    }
331321
public static function newName($name)
    {
        if (file_exists($name)) {
            $extension = self::getFileExtension($name);
            $name = substr($name,0,(-strlen($extension)-1)) . '_' . sha1(uniqid(rand(), true)) . ".$extension";
        }
        return $name;
    }
658117
public function extension(string $name): bool
    {
        $files = $this->app->make('files');

        list($basePath, $sourcePath) = $this->getPathFromExtensionName($name);

        $paths = [
            "{$basePath}/resources/database/migrations/",
            "{$basePath}/resources/migrations/",
            "{$basePath}/database/migrations/",
        ];

        // We don't execute the same migration twice, this little code
        // compare both folder before appending the paths.
        if ($basePath !== $sourcePath && ! empty($sourcePath)) {
            $paths = array_merge($paths, [
                "{$sourcePath}/resources/database/migrations/",
                "{$sourcePath}/resources/migrations/",
                "{$sourcePath}/database/migrations/",
            ]);
        }

        foreach ($paths as $path) {
            if ($files->isDirectory($path)) {
                $this->run($path);
            }
        }

        return true;
    }
20197
public function validNameFile($filename,$ext=true){
        $filename = trim($filename);
        if($filename!="." && $filename!=".." && $filename!=" " && preg_match_all("#^[a-zA-Z0-9-_.\s]+$#",$filename) > 0){
            if($ext) return $this->validExt($filename);
            else return true;
        }else{
            return false;
        }
    }
642340
private function _createFile($dir, $name, $ext)
    {
        if (!empty($this->rootDir)) {
            if (!file_exists($this->_getFileDir($dir))) {
                mkdir($this->_getFileDir($dir), 0777, true);
            }
            if (!file_exists($this->_getFilePath($dir, $name, $ext))) {
                if (file_put_contents($this->_getFilePath($dir, $name, $ext), '') === false) {
                    throw new \Exception("Could not create $ext for {$this->username}.");
                }
            }
        }
    }
482966
protected function validateFileType($name)
    {
        $extension = strtolower(File::extension($name));

        $allowedFileTypes = FileDefinitions::get('defaultExtensions');

        if (!in_array($extension, $allowedFileTypes)) {
            return false;
        }

        return true;
    }
247604
public function removeExtension($name)
    {
        if (isset($this->extensions[$name])) {
            unset($this->extensions[$name]);
        }

        return $this;
    }
145315
public function getExtension($name)
    {
        if ($this->hasExtension($name)) {
            return $this->_extensions[$name];
        }

        throw new OutOfBoundsException(get_class($this).": No extension named \"$name\" found");
    }
25962
public static function trim_extension_off($name)
    {
        if (strrpos($name, '.') !== false) {
            return substr($name, 0, strrpos($name, '.'));
        }
        
        return $name;
    }
634323
public static File[] listFiles(final String ext) {
		init();
		
		return config.listFiles(new FilenameFilter() {

			public boolean accept(File dir, String name) {
				return name.endsWith(ext);
			}
		});
	}
97233
public function extName($extName = null)
    {
        if (func_num_args() > 0) {
            $parts = pathinfo($this->_name);
            $this->_name = "{$parts['dirname']}/{$parts['filename']}.{$extName}";
            return $this;
        }
        return pathinfo($this->_name, PATHINFO_EXTENSION);
    }
216559
public function getAdapterByExt($ext)
    {
        if (null === $adapter = $this->determineWhichAdapterToUse('.'.$ext)) {
            throw new RendererException("Unable to find adapter for '.$ext'.", RendererException::SCRIPTFILE_ERROR);
        }

        return $adapter;
    }
191120
private function deriveExtensionMapping($name, array $extensions)
    {
        // Iterate through all of the extensions
        foreach($extensions as $extension)
        {
            // Check if it exists
            if(!isset($this->extensionMapping[$extension]))
            {
                // It doesn't, so initialize it
                $this->extensionMapping[$extension] = array();
            }

            // Add a mapping between the two
            $this->extensionMapping[$extension][] = $name;
        }
    }
1216394
protected function normalizeName($name)
    {
        if ($this->files->extension($name) === $this->extension) {
            $name = substr($name, 0, - (strlen($this->extension) + 1));
        }

        return $name;
    }
1096569
protected function getFileName($name)
    {
        $fileName = $this->baseDir . '/' . $name;
        if (substr($fileName, 0 - strlen($this->extension)) !== $this->extension) {
            $fileName .= $this->extension;
        }

        return $fileName;
    }
573500
public static function getTypeFromExt($ext) {
        if (isset(self::$_types[$ext])) {
            $mime = self::$_types[$ext];

            if (is_array($mime)) {
                $mime = $mime[0];
            }

            return $mime;
        }

        throw new InvalidArgumentException(sprintf('Invalid extension %s', $ext));
    }
1202644
public static function get_name($file, $ext = false) {
        $name = trim($file['name']);
        $name = str_replace(' ', '', $name);
        $name = str_replace('　', '', $name);
        if ($ext) {
            return $name;
        }
        $pos = strrpos($name, '.');
        if ($pos === false) {
            return $name;
        }
        return trim(substr($name, 0, $pos));
    }