Parameter: $filename type string
425625
public static function load($filename)
	{
		$btree = null;

		if (!file_exists($filename))
		{
			return null;
		}
		$lines = file($filename);

		foreach ($lines as $i=>$linha)
		{
			if (substr($linha,0,1) != '+')
			{
				$bnode = new BTreeNode($linha);
				$btree = BTree::insert($bnode, $btree);
			}
			else
			{
				$bnode->addValue(substr($linha,1));
			}
		}
		return $btree;
	}
1154735
def type(filename):
    
    assert isinstance(filename, basestring)
    while 1:
        filename, suffix = os.path.splitext (filename)
        if not suffix: return None
        suffix = suffix[1:]

        if suffix in __suffixes_to_types:
            return __suffixes_to_types[suffix]
1135006
function getFromFileNameV2 (filename) {
	var result = mime.getType(filename);

	// Add charset just in case for some buggy browsers.
	if (result === 'application/javascript' || result === 'application/json' || result === 'text/plain') {
		result += '; charset=UTF-8';
	}

	return result;
}
1336859
function check(filename) {
  this.filename = filename && path.resolve(filename) || '';
  this.types = [];
  this.valid = null;
}
323282
def __filename(self, id):
        """"""
        suffix = self.fnsuffix()
        filename = "%s-%s.%s" % (self.fnprefix, id, suffix)
        return os.path.join(self.location, filename)
1118458
public static function getMimeTypeFromFilename($fileName)
    {
        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (array_key_exists($ext, self::$customMimeTypes)) {
            return self::$customMimeTypes[$ext];
        } else if (array_key_exists($ext, self::$mimeTypes)) {
            return self::$mimeTypes[$ext];
        }
        return 'application/octet-stream';
    }
373627
static function _NormalizeFilename($filename){
		$_filename = "";
		while(1){
			$_filename = preg_replace('/[^\/]+\/+\.\.\//','/',$filename); // "/path/to/dir/../tmp/images/" -> "/path/to/tmp/images/"
			if($_filename==$filename){ break; }
			$filename = $_filename;
		}
		$filename = $_filename;

		$filename = preg_replace('/\/\/+/','/',$filename); // "/path/to//tmp/dir//" -> "/path/to/tmp/dir/"

		return $filename;
	}
1212874
private function applyStringReplacements(
        $filename
    ): string {
        $stringReplacements = [];
        if ($stringReplacements) {
            $contents = file_get_contents($filename);
            foreach ($stringReplacements as $search => $replace) {
                $contents = str_replace($search, $replace, $contents);
            }
            // @todo Use of tmpfile ok here? These will be small, managed files. I don't foresee hitting a disk space
            //       issue here
            $tempFile = tmpfile();
            fwrite($tempFile, $contents);
            $metaData = stream_get_meta_data($tempFile);
            $filename = $metaData["uri"];
        }
        return $filename;
    }
657801
def parseFilename(filename):
    

    # Parse out any extension specified in filename
    _indx = filename.find('[')
    if _indx > 0:
        # Read extension name provided
        _fname = filename[:_indx]
        _extn = filename[_indx + 1:-1]
    else:
        _fname = filename
        _extn = None

    return _fname, _extn
1226775
public static function mapFileNameToClassName($fileName)
    {
        $matches = [];
        if (preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches)) {
            $fileName = $matches[1];
        }

        return str_replace(' ', '', ucwords(str_replace('_', ' ', $fileName)));
    }
610201
protected function parseFileName($fileName)
    {
        return preg_replace_callback('#(\[.*\])#U', function ($matches) {
            $format = str_replace(['[',']'], [], $matches[1]);

            return $this->now->format($format);
        }, $fileName);
    }
1369753
static function safeName($filename,$unsafeExtensions=null,$safeExtension="txt") {
		if ($unsafeExtensions===null) $unsafeExtensions=array("php","phtml","inc","php3","php4","php5");
		if ($filename[0] == '.') {
			$filename = substr($filename, 1);
		}
		$filename = str_replace(DIRECTORY_SEPARATOR, '-', $filename);
		$extension=self::extension($filename, "l");
		if (in_array($extension, $unsafeExtensions)) {
			$extension=$safeExtension;
		}
		$name=self::filenameWithoutExtension($filename);
		$name=Strings::safe($name, false);
		if (preg_match('~^(.*)[-_]+$~',$name,$partsName)) {
			$name=$partsName[1];
		}
		if (preg_match('~^[-_]+(.*)$~',$name,$partsName)) {
			$name=$partsName[1];
		}
		$ret=$name;
		if ($extension) $ret.=".".$extension;
		return $ret;
	}
288103
private static function guessFromFileCommand(string $filename): string
    {
        $result = 'application/octet-stream';

        if (!self::isCommandAvailable('file')) {
            return $result;
        }

        $info = trim(shell_exec('file -bi '.escapeshellarg($filename)));

        return $info != '' ? $info : $result;
    }
208521
def _filenames_from_arg(filename):
    """"""
    if isinstance(filename, string_types):
        filenames = [filename]
    elif isinstance(filename, (list, tuple)):
        filenames = filename
    else:
        raise Exception('filename argument must be string, list or tuple')
    for fn in filenames:
        if not os.path.exists(fn):
            raise ValueError('file not found: %s' % fn)
        if not os.path.isfile(fn):
            raise ValueError('not a file: %s' % fn)
    return filenames
843705
public function setFileName($fileName)
    {
        $this->fileName = $fileName;
        $this->setContentType(mime_content_type($this->fileName));
    }
442819
def file_type(filename, param='rb'):
    """"""
    magic_dict = {
        b"\x1f\x8b\x08": "gz",
        b"\x42\x5a\x68": "bz2",
        b"\x50\x4b\x03\x04": "zip"
    }
    if param.startswith('w'):
        return filename.split('.')[-1]
    max_len = max(len(x) for x in magic_dict)
    with open(filename, 'rb') as f:
        file_start = f.read(max_len)
    for magic, filetype in list(magic_dict.items()):
        if file_start.startswith(magic):
            return filetype
    return "no match"
74412
def filename(value):
        '''
        
        '''
        return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))