(native_path)
Return Windows short path name or None if not available.
Return Windows short path name or None if not available.
Return Windows short path name or None if not available .
def get_short_pathname(native_path):
    """Return Windows short path name or None if not available."""
    try:
        length = _GetShortPathName(native_path, LPWSTR(0), DWORD(0))
        wbuffer = ctypes.create_unicode_buffer(length)
        _GetShortPathName(native_path, wbuffer, DWORD(length))
    except Exception as e:
        # something went wrong - this should be a WindowsError which is an OSError
        # but not clear
        return None
    else:
        # can also be None in wbuffer.value if error
        return wbuffer.value
def get_short_pathname ( native_path ) : try : length = _GetShortPathName ( native_path , LPWSTR ( 0 ) , DWORD ( 0 ) ) wbuffer = ctypes . create_unicode_buffer ( length ) _GetShortPathName ( native_path , wbuffer , DWORD ( length ) ) except Exception as e : # something went wrong - this should be a WindowsError which is an OSError # but not clear return None else : # can also be None in wbuffer.value if error return wbuffer . value