MCPcopy Create free account
hub / github.com/ipython/ipython / _get_long_path_name

Function _get_long_path_name

IPython/utils/path.py:30–53  ·  view source on GitHub ↗

Get a long path name (expand ~) on Windows using ctypes. Examples -------- >>> get_long_path_name('c:\\docume~1') 'c:\\\\Documents and Settings'

(path)

Source from the content-addressed store, hash-verified

28
29if sys.platform == 'win32':
30 def _get_long_path_name(path):
31 """Get a long path name (expand ~) on Windows using ctypes.
32
33 Examples
34 --------
35
36 >>> get_long_path_name('c:\\docume~1')
37 'c:\\\\Documents and Settings'
38
39 """
40 try:
41 import ctypes
42 except ImportError:
43 raise ImportError('you need to have ctypes installed for this to work')
44 _GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
45 _GetLongPathName.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p,
46 ctypes.c_uint ]
47
48 buf = ctypes.create_unicode_buffer(260)
49 rv = _GetLongPathName(path, buf, 260)
50 if rv == 0 or rv > 260:
51 return path
52 else:
53 return buf.value
54else:
55 def _get_long_path_name(path):
56 """Dummy no-op."""

Callers 1

get_long_path_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected