(native_path, dosname, isdir)
return None
Find a matching native file name for a given normalised DOS name.
Find a matching native file name for a given normalised DOS name.
Find a matching native file name for a given normalised DOS name .
def dos_to_native_name(native_path, dosname, isdir):
    """Find a matching native file name for a given normalised DOS name."""
    try:
        uni_name = dosname.decode('ascii')
    except UnicodeDecodeError:
        # non-ascii characters are not allowable for DOS filenames, no match
        return None
    # check if the 8.3 uppercase exists, prefer if so
    if istype(native_path, uni_name, isdir):
        return uni_name
    # otherwise try in lexicographic order
    try:
        all_names = os.listdir(native_path)
    except EnvironmentError:
        # report no match if listdir fails
        return None
    for f in sorted(all_names):
        # we won't match non-ascii anyway
        try:
            ascii_name = f.encode('ascii')
        except UnicodeEncodeError:
            continue
        # don't match long names or non-legal dos names
        if dos_is_legal_name(ascii_name):
            try_name = dos_normalise_name(ascii_name)
            if try_name == dosname and istype(native_path, f, isdir):
                return f
    return None
def dos_to_native_name ( native_path , dosname , isdir ) : try : uni_name = dosname . decode ( 'ascii' ) except UnicodeDecodeError : # non-ascii characters are not allowable for DOS filenames, no match return None # check if the 8.3 uppercase exists, prefer if so if istype ( native_path , uni_name , isdir ) : return uni_name # otherwise try in lexicographic order try : all_names = os . listdir ( native_path ) except EnvironmentError : # report no match if listdir fails return None for f in sorted ( all_names ) : # we won't match non-ascii anyway try : ascii_name = f . encode ( 'ascii' ) except UnicodeEncodeError : continue # don't match long names or non-legal dos names if dos_is_legal_name ( ascii_name ) : try_name = dos_normalise_name ( ascii_name ) if try_name == dosname and istype ( native_path , f , isdir ) : return f return None