Gets the short path name of a given long path. http://stackoverflow.com/a/23598461/200291
(_path)
| 172 | _GetShortPathNameW.restype = wintypes.DWORD |
| 173 | |
| 174 | def fs_short_path(_path): |
| 175 | """ |
| 176 | Gets the short path name of a given long path. |
| 177 | http://stackoverflow.com/a/23598461/200291 |
| 178 | """ |
| 179 | buf_size = len(_path) |
| 180 | while True: |
| 181 | res = ctypes.create_unicode_buffer(buf_size) |
| 182 | # Note:- _GetShortPathNameW may return empty value |
| 183 | # if directory doesn't exist. |
| 184 | needed = _GetShortPathNameW(_path, res, buf_size) |
| 185 | |
| 186 | if buf_size >= needed: |
| 187 | return res.value |
| 188 | else: |
| 189 | buf_size += needed |
| 190 | |
| 191 | def document_dir(): |
| 192 | CSIDL_PERSONAL = 5 # My Documents |
no outgoing calls
no test coverage detected