def secure_filename(path, destiny_os=os.name, fs_encoding=compat.FS_ENCODING):
path = generic_filename(path)<EOL>path = clean_restricted_chars(<EOL>path,<EOL>restricted_chars=(<EOL>nt_restricted_chars<EOL>if destiny_os == '<STR_LIT>' else<EOL>restricted_chars<EOL>))<EOL>path = path.strip('<STR_LIT>')  <EOL>if check_forbidden_filename(path, destiny_os=destiny_os):<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if isinstance(path, bytes):<EOL><INDENT>path = path.decode('<STR_LIT>', errors=underscore_replace)<EOL><DEDENT>kwargs = {<EOL>'<STR_LIT>': destiny_os,<EOL>'<STR_LIT>': fs_encoding,<EOL>'<STR_LIT>': underscore_replace,<EOL>}<EOL>fs_encoded_path = compat.fsencode(path, **kwargs)<EOL>fs_decoded_path = compat.fsdecode(fs_encoded_path, **kwargs)<EOL>return fs_decoded_path<EOL>
Get rid of parent path components and special filenames.

If path is invalid or protected, return empty string.

:param path: unsafe path, only basename will be used
:type: str
:param destiny_os: destination operative system (defaults to os.name)
:type destiny_os: str
:param fs_encoding: fs path encoding (defaults to detected)
:type fs_encoding: str
:return: filename or empty string
:rtype: str