def decode_filesystem_name(filename):
result = []<EOL>remain = filename<EOL>i = <NUM_LIT:0><EOL>while remain:<EOL><INDENT>match = _FILESYSTEM_TOKEN_RE.match(remain)<EOL>if not match:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (filename, i,<EOL>remain[:<NUM_LIT:2>]))<EOL><DEDENT>match_str = match.group(<NUM_LIT:0>)<EOL>match_len = len(match_str)<EOL>i += match_len<EOL>remain = remain[match_len:]<EOL>match_dict = match.groupdict()<EOL>if match_dict['<STR_LIT>']:<EOL><INDENT>result.append(str(match_str))<EOL><DEDENT>elif match_dict['<STR_LIT>']:<EOL><INDENT>result.append('<STR_LIT:_>')<EOL><DEDENT>elif match_dict['<STR_LIT>']:<EOL><INDENT>result.append(str(match_dict['<STR_LIT>'].upper()))<EOL><DEDENT>elif match_dict['<STR_LIT:N>']:<EOL><INDENT>N = int(match_dict['<STR_LIT:N>'])<EOL>if N == <NUM_LIT:0>:<EOL><INDENT>N = <NUM_LIT:1><EOL><DEDENT>bytes_len = <NUM_LIT:2> * N<EOL>i += bytes_len<EOL>bytes = remain[:bytes_len]<EOL>remain = remain[bytes_len:]<EOL>if not _HEX_RE.match(bytes):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (filename, i, bytes))<EOL><DEDENT>bytes_repr = '<STR_LIT>'.join('<STR_LIT>' % bytes[i:i + <NUM_LIT:2>]<EOL>for i in range(<NUM_LIT:0>, bytes_len, <NUM_LIT:2>))<EOL>bytes_repr = "<STR_LIT>" % bytes_repr<EOL>result.append(eval(bytes_repr).decode('<STR_LIT:utf8>'))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (filename, i, remain[:<NUM_LIT:2>]))<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(result)<EOL>
Decodes a filename encoded using the rules given in encode_filesystem_name
    to a unicode string.